home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 1 / The 640 Meg Shareware Studio CD-ROM Volume I (Data Express)(1992).ISO / driver / macpab2.dsk / MACPA2.ZIP / MAAPI / AAPIFUNC.TXT < prev    next >
Text File  |  1992-06-30  |  181KB  |  4,258 lines

  1. B64
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.                     IBM M-Audio Capture and Playback Adapter
  19.                     Audio Application Programming Interface
  20.                              Functional Description
  21.  
  22.  
  23.  
  24.  
  25.  
  26.                                  Version 2.00
  27.                                  "C" Language
  28.                                 March 9th, 1992
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.                       (C) Copyright IBM Corporation. 1991
  37.  
  38.  
  39.  
  40.      SUMMARY OF AMENDMENTS
  41.      _____________________
  42.  
  43.  
  44.      VERSION 2.00 - APRIL 2, 1990
  45.      ____________________________
  46.  
  47.      ∙   Pulse Code Modulation (PCM) support
  48.  
  49.          ─   8 or 16 bit sample size
  50.  
  51.          ─   8000, 11025, 22050, or 44100 sample rates
  52.  
  53.          ─   Mono or stereo
  54.  
  55.          ─   Support of Microsoft RIFF WAVE file format
  56.  
  57.      ∙   Source Mix support
  58.  
  59.          Allows the mixing of an analog signal from any of the M-ACPA input
  60.          sources with the output of playing a PCM file.
  61.  
  62.      ∙   Save/Restore support
  63.  
  64.          Allows the caller to save the current state of a play or record opera-
  65.          tion, stop the operation, and then restore the saved state and restart
  66.          the operation.
  67.  
  68.      ∙   Added a function to return the size of audio data structures
  69.  
  70.      ∙   Removed support for ADPCM mix function
  71.  
  72.      Formatting changes are not identified. Similarly, minor clarifications,
  73.      grammatical changes, spelling corrections, etc. are not identified.
  74.  
  75.      Revisions for version 2.00 are marked with a vertical bar.
  76.  
  77.      CHANGE HISTORY
  78.      ______________
  79.  
  80.      ∙   Version 1.02 - 11 January 90
  81.  
  82.          Initial release in Audio Visual Connection product.
  83.  
  84.      ∙   Version 1.03 - July 2, 1990
  85.  
  86.          ─   Added support for MIDI audio type
  87.  
  88.          ─   Added Pause/Resume controls
  89.  
  90.          ─   Added support for High Quality Music (ADPCM 22K MONO)
  91.  
  92.  
  93.                                               Summary of Amendments  ii
  94.  
  95.  
  96.  
  97.      ∙   Version 2.00 - 2 April 91
  98.  
  99.          Initial release with M-ACPA.
  100.  
  101.          Current version
  102.  
  103.  
  104.                                              Summary of Amendments  iii
  105.  
  106.  
  107.      CONTENTS
  108.      ________
  109.  
  110.  
  111.      1.  Introduction   . . . . . . . . . . . . . . . . . . . . . . . . . .   1
  112.  
  113.      2.  Overview   . . . . . . . . . . . . . . . . . . . . . . . . . . . .   2
  114.      2.1  High Level Example  . . . . . . . . . . . . . . . . . . . . . . .   3
  115.  
  116.      3.  AAPI Functions   . . . . . . . . . . . . . . . . . . . . . . . . .   4
  117.      3.1   Audio File Functions   . . . . . . . . . . . . . . . . . . . . .   4
  118.        3.1.1   FAB_TYPE - Determine type of audio file  . . . . . . . . . .   4
  119.        3.1.2   FAB_OPEN - Open an AVC audio file  . . . . . . . . . . . . .   6
  120.        3.1.3   FAB_ROPN - Open a RIFF WAVE audio file   . . . . . . . . . .   9
  121.        3.1.4   FAB_SAVE - Save changes in an audio file   . . . . . . . . .  11
  122.        3.1.5   FAB_CLOSE - Close an audio file  . . . . . . . . . . . . . .  12
  123.      3.2   Audio Control Functions  . . . . . . . . . . . . . . . . . . . .  13
  124.        3.2.1   AUD_SIZE - Return size of audio structures   . . . . . . . .  13
  125.        3.2.2   AUD_CFIG - Get audio device configuration  . . . . . . . . .  14
  126.        3.2.3   AUD_INIT - Initialize audio processing   . . . . . . . . . .  15
  127.        3.2.4   AUD_SET - Set up an audio operation  . . . . . . . . . . . .  17
  128.        3.2.5   AUD_STRT - Start an audio operation  . . . . . . . . . . . .  26
  129.        3.2.6   AUD_CTRL  - Control an audio operation   . . . . . . . . . .  31
  130.        3.2.7   AUD_TERM - Terminate audio processing  . . . . . . . . . . .  35
  131.  
  132.      4.  Control Data Structures  . . . . . . . . . . . . . . . . . . . . .  37
  133.      4.1  Audio Device Control Block (ADCB)   . . . . . . . . . . . . . . .  37
  134.      4.2  Audio Start/Stop List Structure (ALST)  . . . . . . . . . . . . .  38
  135.      4.3  Audio Control Block (ACB)   . . . . . . . . . . . . . . . . . . .  39
  136.      4.4  Audio Format Structure  (AFMT)  . . . . . . . . . . . . . . . . .  47
  137.  
  138.      5.  Usage Examples   . . . . . . . . . . . . . . . . . . . . . . . . .  49
  139.      5.1  Check audio hardware and software configuration   . . . . . . . .  49
  140.      5.2  Play (single channel)   . . . . . . . . . . . . . . . . . . . . .  49
  141.      5.3  Record/Monitor  . . . . . . . . . . . . . . . . . . . . . . . . .  50
  142.      5.4  Play (two channel)  . . . . . . . . . . . . . . . . . . . . . . .  50
  143.  
  144.      6.  AVC Audio File Format  . . . . . . . . . . . . . . . . . . . . . .  52
  145.      6.1  Audio File Overview   . . . . . . . . . . . . . . . . . . . . . .  52
  146.        6.1.1  Audio File Types  . . . . . . . . . . . . . . . . . . . . . .  52
  147.          6.1.1.1  "AUDIO" File  . . . . . . . . . . . . . . . . . . . . . .  52
  148.          6.1.1.2  "ESCAPE" FILE   . . . . . . . . . . . . . . . . . . . . .  52
  149.        6.1.2  Audio Object Types  . . . . . . . . . . . . . . . . . . . . .  52
  150.      6.2  File Data Structures  . . . . . . . . . . . . . . . . . . . . . .  55
  151.        6.2.1  Directory Control Block   . . . . . . . . . . . . . . . . . .  56
  152.        6.2.2  File Access Block (FAB)   . . . . . . . . . . . . . . . . . .  59
  153.        6.2.3  Audio Objects   . . . . . . . . . . . . . . . . . . . . . . .  62
  154.          6.2.3.1  Object Descriptions   . . . . . . . . . . . . . . . . . .  63
  155.  
  156.      7.  RIFF WAVE Audio File Format  . . . . . . . . . . . . . . . . . . .  68
  157.      7.1  Audio File Overview   . . . . . . . . . . . . . . . . . . . . . .  68
  158.  
  159.      Appendix A.  OS/2 Considerations   . . . . . . . . . . . . . . . . . .  69
  160.  
  161.  
  162.                                                            Contents  iv
  163.  
  164.  
  165.  
  166.      A.1   OS/2 Usage   . . . . . . . . . . . . . . . . . . . . . . . . . .  69
  167.      A.2   OS/2 Device Driver   . . . . . . . . . . . . . . . . . . . . . .  69
  168.  
  169.      Appendix B.  DOS Considerations  . . . . . . . . . . . . . . . . . . .  70
  170.      B.1   DOS Usage  . . . . . . . . . . . . . . . . . . . . . . . . . . .  70
  171.      B.2   DOS Device Driver  . . . . . . . . . . . . . . . . . . . . . . .  70
  172.      B.3   DOS Reentrancy   . . . . . . . . . . . . . . . . . . . . . . . .  70
  173.      B.4   Expanded Memory  . . . . . . . . . . . . . . . . . . . . . . . .  70
  174.  
  175.      Appendix C.  Additional Information on PCM Support   . . . . . . . . .  71
  176.      C.1  Significance of the Different PCM Modes   . . . . . . . . . . . .  71
  177.        C.1.1  Sample Rate   . . . . . . . . . . . . . . . . . . . . . . . .  71
  178.        C.1.2  Sample Width  . . . . . . . . . . . . . . . . . . . . . . . .  73
  179.      C.2  Mu-Law and A-Law Companding   . . . . . . . . . . . . . . . . . .  76
  180.      C.3  Dither  . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  78
  181.      C.4  Volume, Balance, Ramp and Pan   . . . . . . . . . . . . . . . . .  80
  182.        C.4.1  Master Volume   . . . . . . . . . . . . . . . . . . . . . . .  80
  183.        C.4.2  Track Volume  . . . . . . . . . . . . . . . . . . . . . . . .  81
  184.        C.4.3  Ramp Rate   . . . . . . . . . . . . . . . . . . . . . . . . .  81
  185.        C.4.4  Balance   . . . . . . . . . . . . . . . . . . . . . . . . . .  82
  186.        C.4.5  Pan Rate  . . . . . . . . . . . . . . . . . . . . . . . . . .  83
  187.      C.5  Source Mixing   . . . . . . . . . . . . . . . . . . . . . . . . .  83
  188.  
  189.  
  190.                                                            Contents  v
  191.  
  192.  
  193.  
  194.      1.  INTRODUCTION
  195.      ________________
  196.  
  197.  
  198.      The Audio Application Programming Interface (AAPI)  is a set of high level
  199.      "C" functions allowing easy application  program access to the audio hard-
  200.      ware  function  and  the  stored digitized  audio.   These  functions  are
  201.      intended to be  at a level appropriate to shield  the application programs
  202.      from the hardware and the various digitized audio formats, but not so high
  203.      a level as to implement functions unique to various applications.
  204.  
  205.      There are two function  sets in the AAPI.  The first  set allows access to
  206.      audio files, and  the data within the files.  The  second set of functions
  207.      is used to control audio operations such as play and record.
  208.  
  209.      There are  two types  of audio  file formats supported  by the  AAPI.  The
  210.      Audio Video Connection file format can be  is used to play and record com-
  211.      pressed audio.  These  files contain audio data that  was compressed using
  212.      an  Adaptive Differential  Pulse Code  Modulation (ADPCM)  technique.  The
  213.      Microsoft  Resource Interchange  File  Format Waveform  Audio File  Format
  214.      (RIFF WAVE) is  used to play and record un-compressed  audio.  These files
  215.      contain Pulse Code Modulation (PCM) data.
  216.  
  217.      The suggested way  to quickly understand the AAPI and  get started writing
  218.      an application is to browse this  document and then study the example pro-
  219.      grams  (play.c, 2play.c,  and record.c)  provided with  the AAPI  package.
  220.      After studying the  example programs use this document as  a reference for
  221.      more detailed information.
  222.  
  223.  
  224.                                                     1.  Introduction  1
  225.  
  226.  
  227.  
  228.      2.  OVERVIEW
  229.      ____________
  230.  
  231.  
  232.      The Audio Application Programming Interface (AAPI)  is a set of high level
  233.      "C" functions  intended to  allow applications  to add  audio capabilities
  234.      such as playing and recording with a  minimum of effort.  The AAPI is file
  235.      oriented.  The  application is not  required to understand the  audio file
  236.      formats to use the AAPI.  The AAPI  has functions to open, save, and close
  237.      audio files.   Once the file  is open the  application is not  required to
  238.      read the audio data  to or from the file but only  to pass the information
  239.      about the file returned on the open to subsequent audio functions.
  240.  
  241.      The AAPI supports  two types of audio  files, AVC and RIFF  WAVE.  The AVC
  242.      audio file actually consists of two physical files.  One of the files con-
  243.      tains  the actual  digitized data  and is  called an  "escape" file.   The
  244.      second  file  contains  general  information  about  the  audio  and  sub-
  245.      components called "objects". Together they are referred to as an AVC audio
  246.      file.   See  6, "AVC  Audio  File   Format"  on  page 52  for  a  complete
  247.      description of the AVC file format.  The Microsoft RIFF WAVE file consists
  248.      of only one physical file.   The digitized data and sub-components (called
  249.      chunks)  are contained  in the  same file.  See 7, "RIFF  WAVE Audio  File
  250.      Format" on page 68 for more information on the RIFF WAVE format.
  251.  
  252.      Although these two file formats are quite different, once the AAPI is used
  253.      to open either type of file  they are represented to the application using
  254.      the same in  memory structure.  This structure called a  File Access Block
  255.      (FAB) is filled out and returned when the file is opened.  The application
  256.      does not need to understand the  FAB information but just passes a pointer
  257.      to the  FAB to subsequent  AAPI function calls.   The FAB is  described in
  258.      detail in 6.2.2, "File Access Block (FAB)" on page 59.
  259.  
  260.      Once the audio file is open and  ready for use the application is ready to
  261.      use the AAPI control functions.  In  general these functions take as input
  262.      a structure  called the Audio  Control Block (ACB).  See  4, "Control Data
  263.      Structures" on page 37 for a complete description of the ACB and all other
  264.      control structures.  Once  initialized the ACB must  be maintained between
  265.      calls with the  application only changing defined input fields  for a par-
  266.      ticular function.  The current state of  the audio process is contained in
  267.      the ACB.  The  application can look at  the ACB at any time  to get status
  268.      information once an audio operation such as play or record is in progress.
  269.  
  270.  
  271.                                                         2.  Overview  2
  272.  
  273.  
  274.  
  275.      2.1  HIGH LEVEL EXAMPLE
  276.      _______________________
  277.  
  278.       Below  is a  high level example  of using the  AAPI function  calls.  See
  279.      5, "Usage Examples" on page 49 and the actual "C" example programs shipped
  280.      with the AAPI for more detailed examples.
  281.  
  282.            Determine type of audio file (FAB_TYPE)
  283.  
  284.            If AVC file
  285.  
  286.               Open the file (FAB_OPEN)
  287.  
  288.            Else RIFF WAVE file
  289.  
  290.               Open the file (FAB_ROPN)
  291.  
  292.            Endif
  293.  
  294.            Initialize the Audio Control Block (AUD_INIT)
  295.  
  296.            Determine audio configuration (AUD_CFIG)
  297.  
  298.            Set up for playing or recording (AUD_SET)
  299.  
  300.            Start playing or recording (AUD_START)
  301.  
  302.            While play or record operation in progress
  303.  
  304.              Application specific tasks
  305.  
  306.              Check Audio Control Block for status and position
  307.  
  308.              Control volume or balance  (AUD_CTRL)
  309.  
  310.            End While
  311.  
  312.            Stop playing or recording (AUD_CTRL)
  313.  
  314.            Terminate the Audio Control Block (AUD_TERM)
  315.  
  316.            Save the file if recording has added data (FAB_SAVE)
  317.  
  318.            Close the audio file (FAB_CLOSE)
  319.  
  320.  
  321.                                                         2.  Overview  3
  322.  
  323.  
  324.  
  325.      3.  AAPI FUNCTIONS
  326.      __________________
  327.  
  328.  
  329.      The Audio Application Program Interface functions will be delivered in DOS
  330.      as a  "C" large model static  link library and  in OS/2 as a  dynamic link
  331.      library  (DLL).   See  Appendix A, "OS/2 Considerations"  on  page 69  and
  332.      Appendix B, "DOS Considerations" on page 70  for additional information on
  333.      using the AAPI under specific operating systems.
  334.  
  335.      3.1   AUDIO FILE FUNCTIONS
  336.      __________________________
  337.  
  338.      The following functions  provide the interface to access  audio files, and
  339.      build the  necessary data structures  to interface with the  audio control
  340.      functions.
  341.  
  342.    | 3.1.1   FAB_TYPE - DETERMINE TYPE OF AUDIO FILE
  343.  
  344.    | Description:
  345.      ____________
  346.    |
  347.    | Attempts to open the  requested file and determines if it  is a known type
  348.    | of audio file.
  349.    |
  350.    | Synopsis:
  351.      _________
  352.    |
  353.    |      int fab_type(name, type)      /* Get type of file               */
  354.    |      char *name;                   /* Pointer to file name           */
  355.    |      unsigned int  *type;          /* Pointer to type of file        */
  356.    |
  357.    | Input Parameters:
  358.      _________________
  359.    |
  360.    | Itemized below are the input  parameters that must be initialized properly
  361.    | before the fab_type function is called.
  362.    |
  363.    |
  364.    |        NAME        - Pointer to fully qualified file name
  365.    |
  366.    |        TYPE        - Pointer to field to return type of file
  367.    |
  368.    |                      Returned types are: 0 = No file exists
  369.    |                                          1 = Unknown type
  370.    |                                          2 = AVC
  371.    |                                          4 = RIFF WAVE
  372.    |
  373.    |
  374.    |
  375.    |
  376.    | Output Return Values:
  377.      _____________________
  378.    |
  379.    |         0, Successful
  380.    |      3303, Open failed fatal error
  381.  
  382.  
  383.                                                   3.  AAPI Functions  4
  384.  
  385.  
  386.  
  387.    | Function:
  388.      _________
  389.    |
  390.    | 1.  Checks for existence of file.
  391.    |
  392.    | 2.  If exists, opens the file and checks header for type.
  393.    |
  394.    | 3.  Closes the file.
  395.  
  396.  
  397.                                                   3.  AAPI Functions  5
  398.  
  399.  
  400.      3.1.2   FAB_OPEN - OPEN AN AVC AUDIO FILE
  401.  
  402.      Description:
  403.      ____________
  404.  
  405.      Creates and/or opens  an AVC audio file and  initializes/reads all objects
  406.      associated with the file including the escape file.
  407.  
  408.      Synopsis:
  409.      _________
  410.  
  411.           int fab_open(name, create,    /* Open audio file                */
  412.              expand,object_flag,fabpp,  /*                                */
  413.              aud_sz, vol_sz,            /*                                */
  414.              pnt_sz, lab_sz)            /*                                */
  415.           char          name;           /* File name                      */
  416.           unsigned char create;         /* Create or open file            */
  417.           unsigned char expand;         /* Expand objects in memory       */
  418.           unsigned char object_flag;    /* Specify objects to process     */
  419.           struct fab    *fabpp;         /* Pointer to FAB pointer         */
  420.           unsigned int  aud_sz;         /* Size to allocate audio  object */
  421.           unsigned int  vol_sz;         /*                  volume object */
  422.           unsigned int  pnt_sz;         /*                  points object */
  423.           unsigned int  lab_sz;         /*                  label  object */
  424.  
  425.      Input Parameters:
  426.      _________________
  427.  
  428.      Itemized below are the input  parameters that must be initialized properly
  429.      before the fab_open function is called.
  430.  
  431.             NAME        - A null terminated string that contains
  432.                           the fully qualified name of the file to access.
  433.  
  434.             CREATE      - Operation to perform on file
  435.                           01h = Create then open  - Return error if file exists
  436.                           02h = Open - Return error if file does not exist
  437.                           03h = Any - Open the file, if it does not exist
  438.                                       then create and open
  439.  
  440.             EXPAND      - Size of objects to allocate
  441.                           00h = Use existing size when allocating objects
  442.                           01h = Allocate objects at maximum in memory size
  443.                                 regardless of current size
  444.                           02h = Allocate using values passed by caller
  445.                                 or at current size whichever is greater.
  446.                                  (AUD_SZ, VOL_SZ, PNT_SZ, LAB_SZ)
  447.                                 Sizes for objects not being processed will
  448.                                 be ignored.
  449.  
  450.  
  451.                                                   3.  AAPI Functions  6
  452.  
  453.  
  454.  
  455.             OBJECT_FLAG - "Audio" and "Escape" objects will always be
  456.                           processed.  Additional objects will be processed
  457.                           based on this flag: (Set bits individually)
  458.                           01h = Process "Volume" object
  459.                           02h = Process "Points" object
  460.                           04h = Process "Labels" object
  461.  
  462.             FABPP       - Pointer to area to store allocated
  463.                           and initialized FAB pointer
  464.  
  465.             AUD_SZ      - Size in bytes to allocate for the audio object.
  466.  
  467.             VOL_SZ      - Size in bytes to allocate the volume object.
  468.  
  469.             PNT_SZ      - Size in bytes to allocate the point object.
  470.  
  471.             LAB_SZ      - Size in bytes to allocate the label object.
  472.  
  473.  
  474.      Output Return Values:
  475.      _____________________
  476.  
  477.              0, Successful
  478.           3301, Open failed, file already exists
  479.           3302, Open failed, file doesn't exist
  480.           3303, Audio file open error
  481.           3304, Allocation of FAB failed, insufficient storage
  482.           3305, Allocation of object failed, insufficient storage
  483.           3306, Audio File read error
  484.           3307, Escape file open error
  485.  
  486.      Function:
  487.      _________
  488.  
  489.      1.  Allocates and initializes the FAB and FABOS.
  490.  
  491.      2.  Creates/opens the audio file as requested.
  492.  
  493.      3.  Allocates the object header and data sections.
  494.  
  495.      4.  Reads the objects in from the audio file.
  496.  
  497.      5.  Creates/opens the escape file.
  498.  
  499.      Notes:
  500.      ______
  501.  
  502.      ∙   Any  audio operation  that will  expand  the "audio"  object, such  as
  503.          record or monitor, requires the "volume" object.  The "points" and and
  504.          "labels" objects are always optional.
  505.  
  506.      ∙   The audio  file name and  its extension are  used to build  the escape
  507.          file name.  If the audio file has a three character extension then the
  508.          first  character of  the extension  is used  in the  extension of  the
  509.  
  510.  
  511.                                                   3.  AAPI Functions  7
  512.  
  513.  
  514.  
  515.          escape file.   If the audio file  has no extension or  less than three
  516.          characters only ".ad" is used.  For example,
  517.  
  518.                         AUDIO FILE NAME      ESCAPE FILE NAME
  519.                             name.!au             name.!ad
  520.                             name._au             name._ad
  521.                             name.xau             name.xad
  522.                             name                 name.ad
  523.                             name.xx              name.ad
  524.  
  525.  
  526.                                                   3.  AAPI Functions  8
  527.  
  528.  
  529.  
  530.  
  531.    | 3.1.3   FAB_ROPN - OPEN A RIFF WAVE AUDIO FILE
  532.  
  533.    | Description:
  534.      ____________
  535.    |
  536.    | Creates and/or opens a RIFF WAVE audio file.
  537.    |
  538.    | Synopsis:
  539.      _________
  540.    |
  541.    |      int fab_ropn(name, create,    /* Open audio file                */
  542.    |         fabpp, fmtp)               /*                                */
  543.    |      char          name;           /* File name                      */
  544.    |      unsigned char create;         /* Create or open file            */
  545.    |      struct fab    *fabpp;         /* Pointer to FAB pointer         */
  546.    |      struct afmt   *fmtp;          /* Pointer to PCM format data     */
  547.    |
  548.    | Input Parameters:
  549.      _________________
  550.    |
  551.    | Itemized below are the input  parameters that must be initialized properly
  552.    | before the fab_ropn function is called.
  553.    |
  554.    |
  555.    |        NAME        - A null terminated string that contains
  556.    |                      the fully qualified name of the file to access.
  557.    |
  558.    |        CREATE      - Operation to perform on file
  559.    |                      01h = Create then open  - Return error if file exists
  560.    |                      02h = Open - Return error if file does not exist
  561.    |                      03h = Any - Open the file, if it does not exist
  562.    |                                  then create and open
  563.    |
  564.    |
  565.    |        FABPP       - Pointer to area to store allocated
  566.    |                      and initialized FAB pointer
  567.    |
  568.    |
  569.    |        FMTP        - Pointer to area to store PCM format data.
  570.    |                      If opening an existing file then the AFMT
  571.    |                      structure will be filled in by the FAB_ROPN
  572.    |                      call. If creating a new file then the caller
  573.    |                      must initialize the structure, selecting what
  574.    |                      type of PCM (sampling rate, etc) the file
  575.    |                      should have.  In both cases the AFMT structure
  576.    |                      will then be passed as input to other AAPI calls.
  577.    |
  578.    | Output Return Values:
  579.      _____________________
  580.    |
  581.    |         0, Successful
  582.    |      3301, Open failed, file already exists
  583.    |      3302, Open failed, file doesn't exist
  584.    |      3304, Allocation of FAB failed, insufficient storage
  585.    |      3307, File open error
  586.    |
  587.    | Function:
  588.      _________
  589.  
  590.                                                   3.  AAPI Functions  9
  591.  
  592.  
  593.  
  594.    | 1.  Allocates and initializes the FAB and FABOS.
  595.    |
  596.    | 2.  Creates/opens the audio file as requested.
  597.    |
  598.    | Notes:
  599.      ______
  600.    |
  601.    | ∙   Source Mixing
  602.    |
  603.    |     An  additional function  is available  when playing  PCM files.   This
  604.    |     function  allows any  live input  source from  the ACPA  card such  as
  605.    |     microphone or line input to be played and controlled just like playing
  606.    |     any PCM  file.  To  access this  function, call  FAB_ROPN with  NAME =
  607.    |     "MSRCMIX$" and CREATE = 2.  Once  this device has been opened then use
  608.    |     it just like any other PCM file.
  609.  
  610.  
  611.                                                  3.  AAPI Functions  10
  612.  
  613.  
  614.  
  615.      3.1.4   FAB_SAVE - SAVE CHANGES IN AN AUDIO FILE
  616.  
  617.      Description:
  618.      ____________
  619.  
  620.      Locates all the objects in an audio file and saves the ones that have been
  621.      marked as changed or  that have been requested to be  saved by the caller.
  622.      If the file has never been saved, all objects are saved.
  623.  
  624.      Synopsis:
  625.      _________
  626.  
  627.           int fab_save(fabp, oupdates)  /* Save changes to an audio file  */
  628.           struct fab    *fabp;          /* Pointer to FAB                 */
  629.           unsigned int  oupdates;       /* Specify objects to update      */
  630.  
  631.      Input Parameters:
  632.      _________________
  633.  
  634.      Itemized below are the input  parameters that must be initialized properly
  635.      before the fab_save function is called.
  636.  
  637.             FABP        - Pointer to FAB
  638.  
  639.             OUPDATES    - Objects to update
  640.                           (Set bits individually)
  641.                           01h = Save audio  object
  642.                           02h = Save volume object
  643.                           04h = Save escape object
  644.                           08h = Save points object
  645.                           10h = Save labels object
  646.  
  647.      Output Return Values:
  648.      _____________________
  649.  
  650.              0, Successful
  651.           3304, Insufficient storage to complete operation
  652.           3308, Audio file write failed
  653.  
  654.      Function:
  655.      _________
  656.  
  657.      1.  Locate each object.
  658.  
  659.      2.  Mark object for save if file never saved or caller requested save.
  660.  
  661.      3.  Write the objects marked for change to disk.
  662.  
  663.      Notes:
  664.      ______
  665.  
  666.      ∙   The Audio  Control Block  field "oupdates" may  be passed  directly to
  667.          this function  (as the  "oupdates" parameter)  after an  audio control
  668.          operation.  This will  write any objects that were  changed during the
  669.          audio control operation (such as record) to the audio file.
  670.  
  671.  
  672.                                                  3.  AAPI Functions  11
  673.  
  674.  
  675.  
  676.      3.1.5   FAB_CLOSE - CLOSE AN AUDIO FILE
  677.  
  678.      Description:
  679.      ____________
  680.  
  681.      Closes the  audio file  and de-allocates all  storage associated  with the
  682.      audio file.
  683.  
  684.      Synopsis:
  685.      _________
  686.  
  687.           int fab_close(fabp)           /* Close an audio file            */
  688.           struct fab    *fabp;          /* Pointer to FAB                 */
  689.  
  690.      Input Parameters:
  691.      _________________
  692.  
  693.      Itemized below are the input  parameters that must be initialized properly
  694.      before the fab_close function is called.
  695.  
  696.             FABP        - Pointer to FAB
  697.  
  698.      Output Return Values:
  699.      _____________________
  700.  
  701.           0,  Successful
  702.  
  703.      Function:
  704.      _________
  705.  
  706.      1.  Close the escape file (AVC file type).
  707.  
  708.      2.  Close the audio file.
  709.  
  710.      3.  De-allocate objects.
  711.  
  712.      4.  De-allocate the FAB and FABOs.
  713.  
  714.  
  715.                                                  3.  AAPI Functions  12
  716.  
  717.  
  718.  
  719.      3.2   AUDIO CONTROL FUNCTIONS
  720.      _____________________________
  721.  
  722.      The following  functions provide the  interface to access and  control the
  723.      audio  hardware/digital signal  processing  code and  its supported  oper-
  724.      ations.  These functions  interface with operating system  files using the
  725.      File Access Block (FAB) structure.  This  interface to files can be set up
  726.      using the audio file functions provided  by this program or the caller can
  727.      do his own set up and use only these audio control functions.
  728.  
  729.    | 3.2.1   AUD_SIZE - RETURN SIZE OF AUDIO STRUCTURES
  730.  
  731.    | Description:
  732.      ____________
  733.    |
  734.    | Returns the length in bytes of the requested structure.
  735.    |
  736.    | Synopsis:
  737.      _________
  738.    |
  739.    |      int aud_size(int)             /* Return size of structure       */
  740.    |      int structure_type;           /* Type of structure              */
  741.    |
  742.    | Input Parameters:
  743.      _________________
  744.    |
  745.    | Itemized below are the parameters that must be initialized properly before
  746.    | the aud_size function is called.
  747.    |
  748.    |
  749.    |        structure_type - Type of audio structure to size
  750.    |                      01h - Audio Device Structure
  751.    |                      02h - Audio Control Block
  752.    |                      03h - Save/Restore Area
  753.    |                      04h - Start/Stop List
  754.    |
  755.    | Output Return Values:
  756.      _____________________
  757.    |
  758.    |
  759.    |   N, Size in bytes of structure
  760.  
  761.  
  762.                                                  3.  AAPI Functions  13
  763.  
  764.  
  765.  
  766.      3.2.2   AUD_CFIG - GET AUDIO DEVICE CONFIGURATION
  767.  
  768.      Description:
  769.      ____________
  770.  
  771.      Access and return configuration information and status on the audio device
  772.      and any corresponding device driver.
  773.  
  774.      Synopsis:
  775.      _________
  776.  
  777.           int aud_cfig(adcbptr)         /* Get configuration information  */
  778.           struct adcb  *adcbptr;        /* Pointer to Audio Device CB     */
  779.  
  780.      Input Parameters:
  781.      _________________
  782.  
  783.      Input ADCB:
  784.      ___________
  785.  
  786.      No input fields.
  787.  
  788.      Output Return Values:
  789.      _____________________
  790.  
  791.              0,  Successful, audio device installed and active
  792.           3224,  Failed, no audio device installed
  793.           3225,  Failed, audio device interrupts are disabled
  794.           3226,  Failed, device driver not responding
  795.  
  796.      Output ADCB:
  797.      ____________
  798.  
  799.      Itemized below are the ADCB fields set by the aud_cfig function.
  800.  
  801.             DEVICE_ID - Microchannel device ID
  802.                           6E6Ch = IBM M-Audio Capture and Playback Adapter
  803.  
  804.             IOBASE    - Audio card base address for program I/O
  805.  
  806.             INTLEVEL  - Audio card hardware interrupt level
  807.  
  808.             OS2RTN    - OS/2 error code
  809.  
  810.      Function:
  811.      _________
  812.  
  813.      1.  If operating system  is OS/2, verifies the device  driver is installed
  814.          and active.  If an error  occurs accessing the device  driver, returns
  815.          (3226) and also returns the OS/2 error code in the ADCB.
  816.  
  817.      2.  Verifies that an audio device is installed, returns (3224) otherwise.
  818.  
  819.      3.  Verifies that interrupts are not disabled, returns (3225) otherwise.
  820.  
  821.      4.  If an audio device is  installed and active, sets configuration infor-
  822.          mation in the ADCB and returns (0).
  823.  
  824.  
  825.                                                  3.  AAPI Functions  14
  826.  
  827.  
  828.  
  829.      3.2.3   AUD_INIT - INITIALIZE AUDIO PROCESSING
  830.  
  831.      Description:
  832.      ____________
  833.  
  834.      Initialize a caller passed Audio Control Block for subsequent AAPI calls.
  835.  
  836.      Synopsis:
  837.      _________
  838.  
  839.           int aud_init(acbptr)          /* Initialize audio processing    */
  840.           struct acb  *acbptr;          /* Pointer to Audio Control Block */
  841.  
  842.      Input Parameters:
  843.      _________________
  844.  
  845.      Input ACB:
  846.      __________
  847.  
  848.      Itemized below are the ACB fields that must be initialized properly before
  849.      the aud_init function is called.
  850.  
  851.             ACB2PTR  - ACB pointer of second track to process
  852.                           00000000h = Single track
  853.  
  854.      All other ACB fields will be initialized by this function.
  855.  
  856.      The following  are the default values  for the audio controls  if the user
  857.      does not explicitly change them:
  858.  
  859.      ∙   I/O buffer length if AAPI allocates storage - 32K bytes
  860.  
  861.      ∙   Master volume level - 100%
  862.  
  863.      ∙   Track volume level - 100%
  864.  
  865.      ∙   Channel balance - 50%
  866.  
  867.      ∙   Output channel pair - A(100%)/B(0%)
  868.  
  869.      ∙   Audio compression type - AVC ADPCM/11K
  870.  
  871.      The ACB must be maintained  between calls (aud_init through aud_term) with
  872.      the  user changing  only defined  input fields  for a  particular function
  873.      call.
  874.  
  875.      Output Return Values:
  876.      _____________________
  877.  
  878.           0,  Successful
  879.  
  880.      Output ACB:
  881.      ___________
  882.  
  883.      Itemized  below are  the ACB  fields set  by the  aud_init function.   All
  884.      output fields marked with "*" are updated  at one tenth of a second inter-
  885.      vals requiring no function call  once an asynchronous (play, record) audio
  886.      operation has been started.
  887.  
  888.                                                  3.  AAPI Functions  15
  889.  
  890.  
  891.  
  892.           * POSITION - Current position in audio (milliseconds)
  893.  
  894.           * STATE    - Current state of signal processor
  895.                           00h = stopped
  896.                           01h = playing
  897.                           02h = recording
  898.                           03h = stopping
  899.  
  900.           * TIMELEFT - Time left before I/O necessary (ms)
  901.  
  902.             OUPDATED - Indication of which objects were changed by AAPI
  903.  
  904.             ACB2RC   - Return code for second ACB operation
  905.  
  906.      Function:
  907.      _________
  908.  
  909.      1.  All input and output fields (except ACB2PTR) will be initialized.
  910.  
  911.      2.  If a secondary ACB is passed in ACB2PTR that ACB will also be initial-
  912.          ized.
  913.  
  914.      Notes:
  915.      ______
  916.  
  917.      ∙   This function will always return successful.
  918.  
  919.  
  920.                                                  3.  AAPI Functions  16
  921.  
  922.  
  923.  
  924.  
  925.      3.2.4   AUD_SET - SET UP AN AUDIO OPERATION
  926.  
  927.      Description:
  928.      ____________
  929.  
  930.      Set up the signal processor and  audio objects so that subsequent calls to
  931.      start and stop audio operations happen immediately.
  932.  
  933.      Synopsis:
  934.      _________
  935.  
  936.           int aud_set(acbptr)           /* Set up audio operations        */
  937.           struct acb  *acbptr;          /* Pointer to Audio Control Block */
  938.  
  939.      Input Parameters:
  940.      _________________
  941.  
  942.      Input ACB:
  943.      __________
  944.  
  945.      Itemized below are the ACB fields that must be initialized properly before
  946.      the aud_set function is called.  Only areas listed should be altered.  All
  947.      other  initialization of  fields  is  done on  a  aud_init  call which  is
  948.      required before  any other type of  AAPI control function calls  are made.
  949.      The ACB must be maintained  between calls (aud_init through aud_term) with
  950.      the  user changing  only defined  input fields  for a  particular function
  951.      call.
  952.  
  953.  
  954.                                                  3.  AAPI Functions  17
  955.  
  956.  
  957.  
  958.             CHANNEL   - Signal processor channel identifier
  959.                           00h = Channel A
  960.                           01h = Channel B
  961.    |                      FFh = An available channel will be selected and
  962.    |                            returned in this field.
  963.  
  964.             DSPMODE   - Set up signal processor for this audio operation
  965.                           01h = Play
  966.                           02h = Record
  967.                           03h = Monitor
  968.  
  969.             SEEKTYPE  - Set up audio object(s) at this position
  970.                           00h = Initialize for new/different audio object
  971.                           01h = Seek to new position in current audio object
  972.                           02h = Continue at next position in current object
  973.                           03h = Release resources only
  974.                           04h = Release resources, then initialize new object
  975.  
  976.             AUDTYPE   - The type of audio compression to use.
  977.                           00h = Use current for existing or default for new
  978.                           01h = Use ADPCM 11K  (AVC mono music)
  979.                           02h = Use ADPCM 5.5K (AVC mono voice)
  980.                           03h = Use ADPCM 22K  (AVC stereo music)
  981.                           04h = Use ADPCM 22K  (AVC mono high quality music)
  982.    |                      3Ch = Use PCM (RIFF WAVE file)
  983.                         Ignored if "DSPMODE" is not record or monitor.
  984.    |                    ADPCM (types 0-4) can only be used with AVC format
  985.    |                    audio files.  PCM (type 3Ch) can only be used with
  986.    |                    RIFF WAVE files.
  987.  
  988.  
  989.                                                  3.  AAPI Functions  18
  990.  
  991.  
  992.  
  993.             INTLEVEL  - Audio card hardware interrupt level
  994.  
  995.             INPSRCE   - Audio card input source
  996.                           00h = Microphone input - normal gain
  997.                           01h = Line level input - left channel
  998.                           02h = Line level input - right channel
  999.                           03h = Line level input - both channel
  1000.                           04h = Microphone input - low gain
  1001.                         Ignored if "DSPMODE" is not record or monitor
  1002.    |                    unless doing "source mix".  Valid options for
  1003.    |                    source mix are 0, 3, and 4.
  1004.  
  1005.             PIOBASE   - Audio card base address for port I/O
  1006.  
  1007.             CONTROLS  - Control changes requested
  1008.                           (Set bits individually)
  1009.                           01h = Master volume
  1010.                           02h = Track volume - 1
  1011.                           04h = Track volume - 2
  1012.                           08h = Channel balance
  1013.                           10h = Set stop position
  1014.                           40h = Pause current operation
  1015.                           80h = Resume current operation
  1016.                         Settings "40h and 80h" are mutually exclusive.
  1017.                         All or none of these controls may be requested.
  1018.  
  1019.             OPRPARMS  - Operation parameters flag
  1020.                           (Set bits individually)
  1021.                           02h = Do not update audio/volume object totals
  1022.                           04h = PS/2 speaker enabled, ignored on non-PS/2
  1023.                           10h = Monitor - record pre-compression
  1024.                           20h = Monitor - record post-compression
  1025.                          200h = Cancel operation if switched to background
  1026.                          400h = Setup VOICE/MIDI DSP environment
  1027.                         Settings "10h and 20h" are mutually exclusive and
  1028.                         ignored if DSPMODE is not monitor.
  1029.  
  1030.             FILEPTR  -  File Access Block pointer
  1031.  
  1032.             SUBTYPE  -  FABO subtype of objects
  1033.  
  1034.             AUDSTART -  Start position for seek (milliseconds)
  1035.                           00000000h = Start of data
  1036.  
  1037.             AUDEND   - End position for seek  (milliseconds)
  1038.                           00000000h = End of data
  1039.  
  1040.             BUFFLEN  - I/O buffer length
  1041.  
  1042.             BUFFPTR  - I/O buffer pointer
  1043.  
  1044.  
  1045.                                                  3.  AAPI Functions  19
  1046.  
  1047.  
  1048.  
  1049.             EMMHAN   - Expanded memory manager handle
  1050.                           Ignored if "MEMID" is not set to "LIM".
  1051.  
  1052.             EMMCNT   - Expanded memory manager page count
  1053.                           Ignored if "MEMID" is not set to "LIM".
  1054.  
  1055.             MEMID    - Memory type id
  1056.                          00h = not allocated
  1057.                          01h = main memory
  1058.                          02h = LIM memory
  1059.                          03h = Device
  1060.                        If memory is not allocated by the caller,
  1061.                        the AAPI will attempt to allocate the size
  1062.                        specified in BUFFLEN from main memory.
  1063.                        If BUFFLEN is zero a default length of 32K
  1064.                        bytes will be allocated.  If the AAPI allocates
  1065.                        the memory it will be released when the caller
  1066.                        does an aud_term.
  1067.  
  1068.             CTLPARMS  - Control parameters flag
  1069.                           (Set bits individually)
  1070.                           01h = Stop - Ignore other control requests  (on)
  1071.                                 Stop - Honor pending control requests (off)
  1072.                             Setting "01h" is ignored if CONTROLS is not set
  1073.                             for "set stop position".
  1074.                           02h = Purge control queue for this channel
  1075.                           08h = Pause/resume all channels      (on)
  1076.                                 Pause/resume only this channel (off)
  1077.                             Setting "08h" is ignored if CONTROLS is not set
  1078.                             for "pause" or "resume".
  1079.    |                      10h = Restore the previous control state. On
  1080.    |                            subsequent calls to "aud_set" this flag can
  1081.    |                            be set to restore the control settings in
  1082.    |                            effect when the last operation was stopped.
  1083.    |                            If the caller passed a pointer to a save area
  1084.    |                            (SVRSPTR) on the initial call to "aud_set" and
  1085.    |                            is resuming at the same place in
  1086.    |                            the same file (SEEKTYPE=2),  then the
  1087.    |                            current state and any pending controls
  1088.    |                            that were queued but not yet executed will
  1089.    |                            be re-queued (including stop requests). If no
  1090.    |                            save area was passed or not restarting where
  1091.    |                            the last operation was stopped then only the
  1092.    |                            last control settings will be restored.
  1093.    |
  1094.    |        MASVOL   - Master volume level (ADPCM 0 - 100/PCM 0 - 120)
  1095.                           Required if "CONTROLS" is set for master volume.
  1096.  
  1097.             TRKVOL1  - Track volume level  (0 - 100)
  1098.                           Required if "CONTROLS" is set for track volume-1.
  1099.  
  1100.             TRKVOL1S - Start position for track volume change (ms)
  1101.                           Required if "CONTROLS" is set for track volume-1.
  1102.  
  1103.  
  1104.                                                  3.  AAPI Functions  20
  1105.  
  1106.  
  1107.  
  1108.             TRKVOL1E - End position for track volume change (ms)
  1109.                           Required if "CONTROLS" is set for track volume-1.
  1110.  
  1111.             TRKVOL2  - Track volume level  (0 - 100)
  1112.                           This field applies to exactly the same control as
  1113.                           TRKVOL1.  This second field gives the caller the
  1114.                           ability to specify two volume fades at different
  1115.                           positions in the audio. If the positions overlap
  1116.                           the caller will be overriding the previous control
  1117.                           change that was requested.
  1118.                           Required if "CONTROLS" is set for track volume-2.
  1119.  
  1120.  
  1121.                                                  3.  AAPI Functions  21
  1122.  
  1123.  
  1124.  
  1125.             TRKVOL2S - Start position for track volume change (ms)
  1126.                           Required if "CONTROLS" is set for track volume-2.
  1127.  
  1128.             TRKVOL2E - End position for track volume change (ms)
  1129.                           Required if "CONTROLS" is set for track volume-2.
  1130.  
  1131.             CHNBAL   - Channel balance (pan) level  (100 - 0)
  1132.                           Required if "CONTROLS" is set for channel balance.
  1133.  
  1134.             OUTCHAN  - Output channel pair for balance
  1135.                           0 = Channel left/right
  1136.                           1 = Channel right/left
  1137.                           Required if "CONTROLS" is set for channel balance.
  1138.  
  1139.             CHNBALS  - Start position for channel balance change (ms)
  1140.                           Required if "CONTROLS" is set for channel balance.
  1141.  
  1142.             CHNBALE  - End position for channel balance change (ms)
  1143.                           Required if "CONTROLS" is set for channel balance.
  1144.  
  1145.             STOPPOS  - Position to stop current operation (ms)
  1146.                           Required if "CONTROLS" is set for set stop position.
  1147.  
  1148.             ACB2PTR  - ACB pointer of second track to process
  1149.                           00000000h = Single track
  1150.  
  1151.             LISTPTR  - Pointer to an Audio Start/Stop List structure.  This
  1152.                           structure contains additional start/stop positions
  1153.                           to be used during play operations.  This structure
  1154.                           also contains a pointer to the next List structure.
  1155.                           This linked list of positions is not used until
  1156.                           the position passed in "AUDEND" has been reached.
  1157.                           00000000h = No additional positions
  1158.  
  1159.             DSP_PATH - Pointer to a fully qualified directory name to use when
  1160.                           accessing DSP files. If this field is zero then
  1161.                           the current directory is used.
  1162.  
  1163.    |        SVRSPTR  - Pointer to a Save/Restore area to be used to restart
  1164.    |                      play and record. See the CTRPARMS description for
  1165.    |                      more information.
  1166.  
  1167.    |        FMTPTR  -  Pointer to an audio format area that contains
  1168.    |                      additional information about the type of audio
  1169.    |                      being played or recorded.  Required only if
  1170.    |                      using a RIFF WAVE file.  Set to 0 for AVC files.
  1171.  
  1172.  
  1173.  
  1174.                                                  3.  AAPI Functions  22
  1175.  
  1176.  
  1177.  
  1178.      Output Return Values:
  1179.      _____________________
  1180.  
  1181.              0, Successful
  1182.           3201, "Audio" object read error
  1183.           3202, "Audio" object not found
  1184.           3203, "Volume" object read error
  1185.           3204, "Volume" object not found
  1186.           3205, "Escape" object read error
  1187.           3206, "Escape" object not found
  1188.           3207, "Escape" file read error
  1189.           3208, I/O buffer allocation failed
  1190.           3209, "audstart" position invalid
  1191.           3210, "audend" position invalid
  1192.           3211, "Escape" file seek error
  1193.           3212, DSP card not responding
  1194.           3213, DSP buffer allocation failed
  1195.           3214, DSP program not found
  1196.           3215, DSP program not readable
  1197.           3216, "dspmode" invalid or audio file/microcode versions
  1198.                       don't match
  1199.           3218, Unable to install audio interrupt service routine
  1200.           3219, "Escape" file write error
  1201.           3220, Control queue overflow, control ignored
  1202.           3221, EMS Save Page Map failed
  1203.           3222, EMS Map Page failed
  1204.           3223, EMS Restore Page Map failed
  1205.           3224,  Microchannel system, but no audio device installed
  1206.           3226,  Device driver not responding
  1207.           3233,  DSP running and requested operation requires reload of DSP
  1208.           3234,  MIDI audio type can not be played on Channel A or in DOS
  1209.           3235,  Device driver error occurred when writing MIDI data
  1210.           3236,  Operating system call failed, system inconsistency
  1211.  
  1212.      Output ACB:
  1213.      ___________
  1214.  
  1215.      Itemized below are the ACB fields set by the aud_set function.  All output
  1216.      fields marked  with "*"  are updated  at one tenth  of a  second intervals
  1217.      requiring  no function  call once  an  operation (play,  record) has  been
  1218.      started.
  1219.  
  1220.           * POSITION - Current position in audio (ms)
  1221.  
  1222.           * STATE    - Current state of signal processor
  1223.                           00h = stopped
  1224.                           01h = playing
  1225.                           02h = recording
  1226.                           03h = stopping
  1227.  
  1228.           * TIMELEFT - Time left before I/O necessary (ms)
  1229.  
  1230.             OUPDATED - Indication of which objects were changed by AAPI
  1231.  
  1232.             ACB2RC   - Return code for second ACB operation
  1233.  
  1234.  
  1235.                                                  3.  AAPI Functions  23
  1236.  
  1237.  
  1238.  
  1239.      Function:
  1240.      _________
  1241.  
  1242.      1.  Based on the requested DSPMODE, if the signal processor is not already
  1243.          in the required mode, the current  mode is terminated and the new mode
  1244.          is initialized.
  1245.  
  1246.      2.  Based  on SEEKTYPE,  if  the  current audio  object(s)  are no  longer
  1247.          needed, the current objects are purged (see notes for more detail) and
  1248.          the requested objects are read as necessary.
  1249.  
  1250.      3.  An open (if not already open) and seek will be done in the escape file
  1251.          to the caller's  requested position. Using the  caller's "BUFFPTR" and
  1252.          "BUFFLEN" the  maximum amount of  audio data  will be pre-loaded  if a
  1253.          play operation is being done.
  1254.  
  1255.      Notes:
  1256.      ______
  1257.  
  1258.    | ∙   The size of the Audio I/O buffer(s) in main memory can be greater than
  1259.    |     64K.  If BUFFLEN  is set for greater  than 64K then it must  be on 64K
  1260.    |     boundaries  (64K, 128K,  192K...)  and the  caller  must allocate  the
  1261.    |     buffer and put the pointer to it in BUFFPTR.
  1262.  
  1263.      ∙   LIM memory can  be passed for the Audio I/O  buffer(s).  The AAPI will
  1264.          always save the  current LIM mapping, remap as required  for the Audio
  1265.          I/O buffer,  and then  restore the original  mapping before  exit.  No
  1266.          remapping for  LIM is  done for  other data items  such as  FABOs.  If
  1267.          other data used  by the AAPI has  been allocated in LIM,  it must have
  1268.          the same mapping as the Audio I/O buffer, or, be mapped correctly upon
  1269.          entry to the AAPI and remain mapped correctly until the AAPI is termi-
  1270.          nated.
  1271.  
  1272.      ∙   An error  on any ACB will  terminate the processing and  the AAPI will
  1273.          return to the caller without processing any additional ACBs.
  1274.  
  1275.    | ∙   During ADPCM recording  the volume and balance controls  are not used.
  1276.    |     The master volume controls the monitor level of the recording but this
  1277.    |     does not affect the recorded data.
  1278.    |
  1279.    | ∙   During PCM recording  the master volume, volume,  and balance controls
  1280.    |     are in  effect and control the  monitor volume and balance  as well as
  1281.    |     the recorded data.
  1282.  
  1283.      ∙   Due to DSP code size and performance restrictions on the M-ACPA signal
  1284.          processor and  the host PC  not all functions  can be loaded  and per-
  1285.          formed simultaneously.  The restrictions are:
  1286.  
  1287.          ─   Recording is limited to one track at a time.
  1288.  
  1289.          ─   Playing two AVC  ADPCM tracks is allowed as long  as neither track
  1290.              is using stereo or high quality audio compression.
  1291.  
  1292.    |     ─   AVC ADPCM and RIFF WAVE files can not be played at the same time.
  1293.  
  1294.  
  1295.                                                  3.  AAPI Functions  24
  1296.  
  1297.  
  1298.  
  1299.    |     ─   Playing two RIFF  WAVE tracks is allowed as long  as neither track
  1300.    |         is stereo, mu-law, or a-law.
  1301.    |
  1302.    |     ─   44KH stereo mu-law or a-law is not allowed.
  1303.    |
  1304.    |     ─   Monitoring  the recorded  output  of an  ADPCM stereo  compression
  1305.    |         track or any PCM track while  it is being recorded is not allowed.
  1306.    |         The  source can  be monitored  during  the recording  but not  the
  1307.    |         result.
  1308.    |
  1309.    |     ─   Source mix can only be used on one PCM track at a time.
  1310.  
  1311.          ─   Playing one track and recording a different track (dubbing) simul-
  1312.              taneously is not allowed.
  1313.  
  1314.          ─   MIDI audio files can only be played in OS/2, not in DOS.
  1315.  
  1316.          ─   MIDI audio  files can only be  played on Track B.   The only audio
  1317.              type that can be played simultaneously with MIDI is ADPCM voice on
  1318.              Track A.  There are two  DSP environments (DSP load modules) where
  1319.              voice can be played, VOICE/MIDI  and VOICE/(VOICE or MUSIC).  Once
  1320.              one of the environments has been  set up and is started,  changing
  1321.              to a  different environment can  not be done without  stopping the
  1322.              DSP.  For  example, if  the VOICE/MIDI  environment is  loaded and
  1323.              VOICE is  playing, only MIDI  can be played simultaneously.   If a
  1324.              MUSIC  file is  now  to be  played  the DSP  must  be stopped  and
  1325.              reloaded.  If the  VOICE/MUSIC environment had been  loaded in the
  1326.              first  place then  both VOICE  and MUSIC  could be  played without
  1327.              stopping the DSP.  If MIDI or MUSIC  is the first audio type to be
  1328.              requested for play,  then there is no choice  on which environment
  1329.              to load.  If VOICE is the  first request then the  caller can pick
  1330.              the environment by  setting on or off the  "Setup VOICE/MIDI" flag
  1331.              in the OPRPARMS field.
  1332.  
  1333.  
  1334.                                                  3.  AAPI Functions  25
  1335.  
  1336.  
  1337.  
  1338.      3.2.5   AUD_STRT - START AN AUDIO OPERATION
  1339.  
  1340.      Description:
  1341.      ____________
  1342.  
  1343.      Start audio processing for the operation requested by the caller.
  1344.  
  1345.      Synopsis:
  1346.      _________
  1347.  
  1348.           int aud_strt(acbptr)          /* Start audio processing         */
  1349.           struct acb  *acbptr;          /* Pointer to Audio Control Block */
  1350.  
  1351.      Input Parameters:
  1352.      _________________
  1353.  
  1354.      Input ACB:
  1355.      __________
  1356.  
  1357.      Itemized below are the ACB fields that must be initialized properly before
  1358.      the aud_strt function is called.   All  other fields should have been ini-
  1359.      tialized on a "aud_init" call and a previous "aud_set" call.  The ACB must
  1360.      be  maintained between  calls (aud_init  through aud_term)  with the  user
  1361.      changing only defined input fields for a particular function call.
  1362.  
  1363.             CONTROLS  - Control changes requested
  1364.                           (Set bits individually)
  1365.                           01h = Master volume
  1366.                           02h = Track volume - 1
  1367.                           04h = Track volume - 2
  1368.                           08h = Channel balance
  1369.                           10h = Set stop position
  1370.                           40h = Pause current operation
  1371.                           80h = Resume current operation
  1372.                         Settings "40h and 80h" are mutually exclusive.
  1373.  
  1374.             CTLPARMS  - Control parameters flag
  1375.                           (Set bits individually)
  1376.                           01h = Stop - Ignore other control requests (on)
  1377.                                 Stop - Honor pending control requests(off)
  1378.                             Setting "01h" is ignored if CONTROLS is not set
  1379.                             for "set stop position".
  1380.                           02h = Purge control queue for this channel
  1381.                           08h = Pause/resume all channels      (on)
  1382.                                 Pause/resume only this channel (off)
  1383.                             Setting "08h" is ignored if CONTROLS is not set
  1384.                             for "pause" or "resume".
  1385.  
  1386.    |        MASVOL   - Master volume level (ADPCM 0 - 100/PCM 0 - 120)
  1387.                           Required if "CONTROLS" is set for master volume.
  1388.  
  1389.  
  1390.                                                  3.  AAPI Functions  26
  1391.  
  1392.  
  1393.  
  1394.             TRKVOL1  - Track volume level  (0 - 100)
  1395.                           Required if "CONTROLS" is set for track volume-1.
  1396.  
  1397.             TRKVOL1S - Start position for track volume change (ms)
  1398.                           Required if "CONTROLS" is set for track volume-1.
  1399.  
  1400.             TRKVOL1E - End position for track volume change (ms)
  1401.                           Required if "CONTROLS" is set for track volume-1.
  1402.  
  1403.             TRKVOL2  - Track volume level  (0 - 100)
  1404.                           This field applies to exactly the same control as
  1405.                           TRKVOL1.  This second field gives the caller the
  1406.                           ability to specify two volume fades at different
  1407.                           positions in the audio. If the positions overlap
  1408.                           the caller will be overriding the previous control
  1409.                           change that was requested.
  1410.                           Required if "CONTROLS" is set for track volume-2.
  1411.  
  1412.             TRKVOL2S - Start position for track volume change (ms)
  1413.                           Required if "CONTROLS" is set for track volume-2.
  1414.  
  1415.             TRKVOL2E - End position for track volume change (ms)
  1416.                           Required if "CONTROLS" is set for track volume-2.
  1417.  
  1418.             CHNBAL   - Channel balance (pan) level  (100 - 0)
  1419.                           Required if "CONTROLS" is set for channel balance.
  1420.  
  1421.             OUTCHAN  - Output channel pair for balance
  1422.                           0 = Channel left/right
  1423.                           1 = Channel right/left
  1424.                           Required if "CONTROLS" is set for channel balance.
  1425.  
  1426.             CHNBALS  - Start position for channel balance change (ms)
  1427.                           Required if "CONTROLS" is set for channel balance.
  1428.  
  1429.             CHNBALE  - End position for channel balance change (ms)
  1430.                           Required if "CONTROLS" is set for channel balance.
  1431.  
  1432.             STOPPOS  - Position to stop current operation (ms)
  1433.                           Required if "CONTROLS" is set for set stop position.
  1434.  
  1435.             ACB2PTR  - ACB pointer of second track to process
  1436.                           00000000h = Single track
  1437.  
  1438.      Output Return Values:
  1439.      _____________________
  1440.  
  1441.  
  1442.                                                  3.  AAPI Functions  27
  1443.  
  1444.  
  1445.  
  1446.              0,  Successful
  1447.           3220,  Control queue overflow, control ignored
  1448.           3227,  Disk full - out of space
  1449.           3228,  Audio object at maximum size
  1450.           3229,  DSP overload - Attempted to play a stereo or HQ music
  1451.                                      track and another track simultaneously
  1452.           3230,  Recording media too slow, recording data lost
  1453.           3231,  Operation cancelled, process not in foreground
  1454.           3232,  Audio file at maximum file length (address space)
  1455.           3233,  DSP running and requested operation requires reload of DSP
  1456.           3234,  MIDI audio type can not be played on Channel A or in DOS
  1457.           3235,  Device driver error occurred when writing MIDI data
  1458.           3236,  Operating system call failed, system inconsistency
  1459.  
  1460.      Output ACB:
  1461.      ___________
  1462.  
  1463.      Itemized  below are  the ACB  fields set  by the  aud_strt function.   All
  1464.      output fields marked with "*" are updated  at one tenth of a second inter-
  1465.      vals  requiring no  function  call once  an  asynchronous audio  operation
  1466.      (play, record) has been started.
  1467.  
  1468.           * POSITION - Current position in audio (ms)
  1469.  
  1470.           * STATE    - Current state of signal processor
  1471.                           00h = stopped
  1472.                           01h = playing
  1473.                           02h = recording
  1474.                           03h = stopping
  1475.  
  1476.           * TIMELEFT - Time left before I/O necessary (ms)
  1477.  
  1478.             OUPDATED - Indication of which objects were changed by AAPI
  1479.  
  1480.           * BACKRC   - Set if error occurs during an operation, between
  1481.                        explicit calls to the AAPI.
  1482.  
  1483.             ACB2RC   - Return code for second ACB operation
  1484.  
  1485.      Function:
  1486.      _________
  1487.  
  1488.      1.  Any control  changes requested  are executed  or queued  for execution
  1489.          before the  operation is started.  This  is true for both  the primary
  1490.          ACB and the secondary ACB.
  1491.  
  1492.      2.  Based on  the requested command(s)  on a previous "aud_set"  call, the
  1493.          requested operation(s) are started.
  1494.  
  1495.      3.  If an  error occurs during  the operation,  but not during  a explicit
  1496.          call to the AAPI, then the "backrc" field is set.  For example, if the
  1497.          disk becomes  full during  a record operation,  the operation  will be
  1498.          stopped, and the appropriate return  code set into the "backrc" field.
  1499.          The caller does not need to  poll this return code continuously during
  1500.          the operation.  If  an error occurs, the operation  will be terminated
  1501.  
  1502.  
  1503.                                                  3.  AAPI Functions  28
  1504.  
  1505.  
  1506.  
  1507.          without waiting  for the  caller to  request a  stop.  The  caller can
  1508.          simple look  at this field after  the operation has stopped  to see if
  1509.          the operation completed successfully.
  1510.  
  1511.      Notes:
  1512.      ______
  1513.  
  1514.      ∙   Play, record, and monitor are  asynchronous operations.  That is, they
  1515.          run independently  until stopped  by an aud_stop  call.  The  user can
  1516.          monitor  the progress  of the  operation using  the ACB  output fields
  1517.          described  above.  The  user can  control the  operation (volume,  I/O
  1518.          request) with additional calls, but the operation continues during and
  1519.          after these additional calls.
  1520.  
  1521.      ∙   Due to DSP code size and performance restrictions on the M-ACPA signal
  1522.          processor and  the host PC  not all functions  can be loaded  and per-
  1523.          formed simultaneously.  The restrictions are:
  1524.  
  1525.          ─   Recording is limited to one track at a time.
  1526.  
  1527.          ─   Playing two AVC  ADPCM tracks is allowed as long  as neither track
  1528.              is using stereo or high quality audio compression.
  1529.  
  1530.    |     ─   AVC ADPCM and  RIFF WAVE PCM files  can not be played  at the same
  1531.    |         time.
  1532.    |
  1533.    |     ─   Playing two RIFF  WAVE tracks is allowed as long  as neither track
  1534.    |         is stereo, mu-law, or a-law.
  1535.    |
  1536.    |     ─   44KH stereo mu-law or a-law is not allowed.
  1537.    |
  1538.    |     ─   Monitoring  the recorded  output  of an  ADPCM stereo  compression
  1539.    |         track or any PCM track while  it is being recorded is not allowed.
  1540.    |         The  source can  be monitored  during  the recording  but not  the
  1541.    |         result.
  1542.    |
  1543.    |     ─   Source mix can only be used on one PCM track at a time.
  1544.  
  1545.          ─   Playing one track and recording a different track (dubbing) simul-
  1546.              taneously is not allowed.
  1547.  
  1548.          ─   MIDI audio files can only be played in OS/2, not in DOS.
  1549.  
  1550.          ─   MIDI audio  files can only be  played on Track B.   The only audio
  1551.              type that can be played simultaneously with MIDI is ADPCM voice on
  1552.              Track A.  There are two  DSP environments (DSP load modules) where
  1553.              voice can be played, VOICE/MIDI  and VOICE/(VOICE or MUSIC).  Once
  1554.              one of the environments has been  set up and is started,  changing
  1555.              to a  different environment can  not be done without  stopping the
  1556.              DSP.  For  example, if  the VOICE/MIDI  environment is  loaded and
  1557.              VOICE is  playing, only MIDI  can be played simultaneously.   If a
  1558.              MUSIC  file is  now  to be  played  the DSP  must  be stopped  and
  1559.              reloaded.  If the  VOICE/MUSIC environment had been  loaded in the
  1560.              first  place then  both VOICE  and MUSIC  could be  played without
  1561.              stopping the DSP.  If MIDI or MUSIC  is the first audio type to be
  1562.  
  1563.  
  1564.                                                  3.  AAPI Functions  29
  1565.  
  1566.  
  1567.  
  1568.              requested for play,  then there is no choice  on which environment
  1569.              to load.  If VOICE is the  first request then the  caller can pick
  1570.              the environment by  setting on or off the  "Setup VOICE/MIDI" flag
  1571.              in the OPRPARMS field.
  1572.  
  1573.  
  1574.                                                  3.  AAPI Functions  30
  1575.  
  1576.  
  1577.  
  1578.      3.2.6   AUD_CTRL  - CONTROL AN AUDIO OPERATION
  1579.  
  1580.      Description:
  1581.      ____________
  1582.  
  1583.      Change the current audio settings or control the operation in progress.
  1584.  
  1585.      Synopsis:
  1586.      _________
  1587.  
  1588.           int aud_ctrl(acbptr)          /* Change audio controls          */
  1589.           struct acb  *acbptr;          /* Pointer to Audio Control Block */
  1590.  
  1591.      Input Parameters:
  1592.      _________________
  1593.  
  1594.      Input ACB:
  1595.      __________
  1596.  
  1597.      Itemized below are the ACB fields that must be initialized properly before
  1598.      the aud_ctrl function  is called.  All other fields should  have been ini-
  1599.      tialized on previous  function calls.  The ACB must  be maintained between
  1600.      calls  (aud_init through  aud_term) with  the user  changing only  defined
  1601.      input fields for a particular function call.
  1602.  
  1603.             CONTROLS  - Control changes requested
  1604.                           (Set bits individually)
  1605.                           01h = Master volume
  1606.                           02h = Track volume - 1
  1607.                           04h = Track volume - 2
  1608.                           08h = Channel balance
  1609.                           10h = Set stop position
  1610.                           20h = Perform I/O
  1611.                           40h = Pause current operation
  1612.                           80h = Resume current operation
  1613.                         Settings "40h and 80h" are mutually exclusive.
  1614.  
  1615.             CTLPARMS  - Control parameters flag
  1616.                           (Set bits individually)
  1617.                           01h = Stop - Ignore other control requests (on)
  1618.                                 Stop - Honor pending control requests(off)
  1619.                              Setting "01h" is ignored if CONTROLS is not set
  1620.                              for "set stop position".
  1621.                           02h = Purge control queue for this channel
  1622.                           04h = This call is being made from an interrupt
  1623.                                 service routine in DOS.  If DOS is "busy" and
  1624.                                 can not be re-entered then the request will not
  1625.                                 be processed and error code 3217 will
  1626.                                 be returned.
  1627.                           08h = Pause/resume all channels      (on)
  1628.                                 Pause/resume only this channel (off)
  1629.                             Setting "08h" is ignored if CONTROLS is not set
  1630.                             for "pause" or "resume".
  1631.  
  1632.             MASVOL   - Master volume level (0 - 100)
  1633.                           Required if "CONTROLS" is set for master volume.
  1634.  
  1635.  
  1636.                                                  3.  AAPI Functions  31
  1637.  
  1638.  
  1639.  
  1640.             TRKVOL1  - Track volume level  (0 - 100)
  1641.                           Required if "CONTROLS" is set for track volume-1.
  1642.  
  1643.             TRKVOL1S - Start position for track volume change (ms)
  1644.                           Required if "CONTROLS" is set for track volume-1.
  1645.  
  1646.             TRKVOL1E - End position for track volume change (ms)
  1647.                           Required if "CONTROLS" is set for track volume-1.
  1648.  
  1649.             TRKVOL2  - Track volume level  (0 - 100)
  1650.                           This field applies to exactly the same control as
  1651.                           TRKVOL1.  This second field gives the caller the
  1652.                           ability to specify two volume fades at different
  1653.                           positions in the audio. If the positions overlap
  1654.                           the caller will be overriding the previous control
  1655.                           change that was requested.
  1656.                           Required if "CONTROLS" is set for track volume-2.
  1657.  
  1658.             TRKVOL2S - Start position for track volume change (ms)
  1659.                           Required if "CONTROLS" is set for track volume-2.
  1660.  
  1661.             TRKVOL2E - End position for track volume change (ms)
  1662.                           Required if "CONTROLS" is set for track volume-2.
  1663.  
  1664.             CHNBAL   - Channel balance (pan) level  (100 - 0)
  1665.                           Required if "CONTROLS" is set for channel balance.
  1666.  
  1667.             OUTCHAN  - Output channel pair for balance
  1668.                           0 = Channel left/right
  1669.                           1 = Channel right/left
  1670.                           Required if "CONTROLS" is set for channel balance.
  1671.  
  1672.             CHNBALS  - Start position for channel balance change (ms)
  1673.                           Required if "CONTROLS" is set for channel balance.
  1674.  
  1675.             CHNBALE  - End position for channel balance change (ms)
  1676.                           Required if "CONTROLS" is set for channel balance.
  1677.  
  1678.             STOPPOS  - Position to stop current operation (ms)
  1679.                           Required if "CONTROLS" is set for set stop position.
  1680.  
  1681.             IOTIME   - The amount of audio data in milliseconds to
  1682.                        read into or write from the audio buffers.
  1683.                           00000000h = Maximum amount of data
  1684.                           Required if "CONTROLS" is set for perform I/O.
  1685.  
  1686.             ACB2PTR  - ACB pointer of second track to process
  1687.                           00000000h = Single track
  1688.  
  1689.      Output Return Values:
  1690.      _____________________
  1691.  
  1692.  
  1693.                                                  3.  AAPI Functions  32
  1694.  
  1695.  
  1696.  
  1697.              0, Successful
  1698.           3207, "Escape" file read error
  1699.           3211, "Escape" file seek error
  1700.           3217, I/O not possible at this time
  1701.           3219, "Escape" file write error
  1702.           3220, Control queue overflow, control ignored
  1703.           3235,  Device driver error occurred when writing MIDI data
  1704.           3236,  Operating system call failed, system inconsistency
  1705.  
  1706.      Output ACB:
  1707.      ___________
  1708.  
  1709.      Itemized  below are  the ACB  fields set  by the  aud_ctrl function.   All
  1710.      output fields marked with "*" are updated  at one tenth of a second inter-
  1711.      vals requiring no function call once  an operation (play, record) has been
  1712.      started.
  1713.  
  1714.           * POSITION - Current position in audio (ms)
  1715.  
  1716.           * STATE    - Current state of signal processor
  1717.                           00h = stopped
  1718.                           01h = playing
  1719.                           02h = recording
  1720.                           03h = stopping
  1721.  
  1722.           * TIMELEFT - Time left before I/O necessary (ms)
  1723.  
  1724.             OUPDATED - Indication of which objects were changed by AAPI
  1725.  
  1726.             ACB2RC   - Return code for second ACB operation
  1727.  
  1728.      Function:
  1729.      _________
  1730.  
  1731.      1.  Control changes are queued for execution based on their order (01, 02,
  1732.          04...) in the "CONTROLS" field and the requested start position in the
  1733.          audio for  that control.  Use  separate aud_ctrl calls if  a different
  1734.          order of  execution is required.   Identical control changes  for dif-
  1735.          ferent channels requested  by setting the control in  both the primary
  1736.          and secondary ACBs will be done  as closely as possible.  For example,
  1737.          all  "master volume"  control  changes will  be  queued for  execution
  1738.          before the next control is considered.
  1739.  
  1740.      Notes:
  1741.      ______
  1742.  
  1743.      ∙   If playing, and a request to "perform I/O" is not made before the data
  1744.          in the audio buffers is  exhausted, the AAPI will begin asynchronously
  1745.          doing the  minimum amount of  I/O needed to  keep the audio  card ser-
  1746.          viced.  Subsequent "perform I/O" requests may be able to replenish the
  1747.          buffers and  re-synchronize the  process but if  this is  not possible
  1748.          asynchronous I/O will continue to be  done until the play operation is
  1749.          stopped.
  1750.  
  1751.      ∙   If recording,  and a request to  "perform I/O" is not  made before the
  1752.          audio buffers  are filled to  capacity, the AAPI will  begin asynchro-
  1753.  
  1754.  
  1755.                                                  3.  AAPI Functions  33
  1756.  
  1757.  
  1758.  
  1759.          nously doing the  minimum amount of I/O needed to  partially empty the
  1760.          audio buffers and accept more audio  data from the audio card.  Subse-
  1761.          quent "perform I/O" requests may be  able to flush the buffers and re-
  1762.          synchronize the process  but if this is not  possible asynchronous I/O
  1763.          will continue to be done until the record operation is stopped.
  1764.  
  1765.      ∙   A stop control request will not  stop the operation immediately if the
  1766.          CTLPARMS flag is set to  honor other controls.  Any controls requested
  1767.          to be executed  or in progress will be allowed  to complete before the
  1768.          stop.  This means that  the audio card must not be  allowed to run out
  1769.          of audio data or overflow the audio buffers before the last control is
  1770.          completed.  The caller must be certain that sufficient data or room is
  1771.          in the  audio buffers before doing  a stop or continue  to do aud_ctrl
  1772.          calls.  The AAPI will do  I/O asynchronously to continue servicing the
  1773.          audio card if necessary if the caller is unable to do aud_ctrl calls.
  1774.  
  1775.  
  1776.                                                  3.  AAPI Functions  34
  1777.  
  1778.  
  1779.  
  1780.      3.2.7   AUD_TERM - TERMINATE AUDIO PROCESSING
  1781.  
  1782.      Description:
  1783.      ____________
  1784.  
  1785.      Terminate audio operations for this ACB
  1786.  
  1787.      Synopsis:
  1788.      _________
  1789.  
  1790.           int aud_term(acbptr)          /* Terminate audio processing     */
  1791.           struct acb  *acbptr;          /* Pointer to Audio Control Block */
  1792.  
  1793.      Input Parameters:
  1794.      _________________
  1795.  
  1796.      Input ACB:
  1797.      __________
  1798.  
  1799.      Itemized below are the ACB fields that must be initialized properly before
  1800.      the aud_term function  is called.  All other fields should  have been ini-
  1801.      tialized  on previous  calls.  The  ACB must  be maintained  between calls
  1802.      (aud_init  through aud_term)  with the  user changing  only defined  input
  1803.      fields for a particular function call.
  1804.  
  1805.             ACB2PTR  - ACB pointer of second track to process
  1806.                           00000000h = Single track
  1807.  
  1808.      Output Return Values:
  1809.      _____________________
  1810.  
  1811.           0,  Successful
  1812.  
  1813.      Output ACB:
  1814.      ___________
  1815.  
  1816.      Itemized  below are  the ACB  fields set  by the  aud_term function.   All
  1817.      output fields marked with "*" are updated  at one tenth of a second inter-
  1818.      vals requiring no function call once  an operation (play, record) has been
  1819.      started.
  1820.  
  1821.             OUPDATED - Indication of which objects were changed by AAPI
  1822.  
  1823.             ACB2RC   - Return code for second ACB operation
  1824.  
  1825.      Function:
  1826.      _________
  1827.  
  1828.      1.  Any interrupt handler/device driver for  the signal processor is deac-
  1829.          tivated.
  1830.  
  1831.      2.  Any objects  that were read  in by the AAPI  and were not  changed are
  1832.          purged from memory.   If the object was already open,  then it is left
  1833.          open but marked as updated if it was changed.
  1834.  
  1835.  
  1836.                                                  3.  AAPI Functions  35
  1837.  
  1838.  
  1839.  
  1840.      3.  If the AAPI allocated the I/O buffer it is de-allocated.
  1841.  
  1842.      Notes:
  1843.      ______
  1844.  
  1845.  
  1846.                                                  3.  AAPI Functions  36
  1847.  
  1848.  
  1849.  
  1850.      4.  CONTROL DATA STRUCTURES
  1851.      ___________________________
  1852.  
  1853.  
  1854.      The following  section provides  descriptions of  the control  blocks used
  1855.      with the audio control type functions of the AAPI.
  1856.  
  1857.      4.1  AUDIO DEVICE CONTROL BLOCK (ADCB)
  1858.      ______________________________________
  1859.  
  1860.      The ADCB is the structure used to retrieve configuration information about
  1861.      the audio device installed in the system.  The only audio device currently
  1862.      supported is the IBM M-Audio Capture and Playback Adapter.
  1863.  
  1864.        ; ** Audio Device Control Block **
  1865.        ; _________________________
  1866.             adcb     struc
  1867.                                       ; *** OUTPUT PARAMETERS ***
  1868.             device_id dw              ; Device ID of audio card
  1869.                                       ;   6E6Ch = IBM M-ACPA (PS/2)
  1870.             iobase    dw              ; I/O address base
  1871.             intlev    dw              ; Hardware interrupt level
  1872.             os2rtn    dw              ; OS/2 error code
  1873.             res       db 10 dup       ; Reserved
  1874.             adcb     ends
  1875.  
  1876.      The parameters  in the AAPI  Device Control  Block can have  the following
  1877.      values:
  1878.  
  1879.      1.  DEVICE_ID - The microchannel device ID of the installed adapter.
  1880.  
  1881.      2.  IOBASE - The starting address of  eight I/O addresses that the adapter
  1882.          has been configured to use.
  1883.  
  1884.      3.  INTLEV - The  hardware interrupt level that the adapter  has been con-
  1885.          figured to use.
  1886.  
  1887.      4.  OS2RTN -  If a call to  OS/2 fails while accessing  the device driver,
  1888.          the OS/2 error code will be returned in this field.
  1889.  
  1890.      5.  RESERVED - A reserved area for future expansion.
  1891.  
  1892.  
  1893.                                         4.  Control Data Structures  37
  1894.  
  1895.  
  1896.  
  1897.      4.2  AUDIO START/STOP LIST STRUCTURE (ALST)
  1898.      ___________________________________________
  1899.  
  1900.      The ALST is the structure used  to pass additional start/stop times to the
  1901.      Audio API during play operations.
  1902.  
  1903.        ; ** Audio Start/Stop List Structure
  1904.        ; _________________________
  1905.             alst     struc
  1906.                                       ;
  1907.             audstart dd               ; Start position for seek (milliseconds)
  1908.             audend   dd               ; End position for seek  (milliseconds)
  1909.             nextlist dd               ; Ptr to next ALST
  1910.             alst     ends
  1911.  
  1912.      The fields in the ALST can have the following values:
  1913.  
  1914.      1.  AUDSTART - Position to start next play operation.
  1915.  
  1916.      2.  AUDEND - Position to end the play operation.
  1917.  
  1918.      3.  NEXTLIST - Pointer  to next structure or null.  If  null the operation
  1919.          will end.  If  not null, playing will continue at  the next "audstart"
  1920.          position. NEXTLIST may  point to itself, or  another structure already
  1921.          processed to create a loop.
  1922.  
  1923.  
  1924.                                         4.  Control Data Structures  38
  1925.  
  1926.  
  1927.  
  1928.      4.3  AUDIO CONTROL BLOCK (ACB)
  1929.      ______________________________
  1930.  
  1931.      The ACB  is the primary control  block used for communication  between the
  1932.      AAPI and  the calling  application program.  The  control block  has input
  1933.      parameters which are used to control how the AAPI interacts with the audio
  1934.      hardware and has output parameters which  the AAPI uses to convey informa-
  1935.      tion back  to the feature  program.  The  control block has  the following
  1936.      structure:
  1937.  
  1938.        ; ** Audio Control Block **
  1939.        ; _________________________
  1940.             acb      struc
  1941.                                       ; *** INPUT PARAMETERS ***
  1942.             channel  db               ; Input channel identifier
  1943.                                       ;   00h = Channel A
  1944.                                       ;   01h = Channel B
  1945.    |                                  ;   FFh = Select and return channel
  1946.             dspmode  db               ; Signal processor operation
  1947.                                       ;   01h = Play
  1948.                                       ;   02h = Record
  1949.                                       ;   03h = Monitor
  1950.             seektype db               ; Type of seek in audio object
  1951.                                       ;   00h = Init/seek in new object
  1952.                                       ;   01h = Seek in current object
  1953.                                       ;   02h = Continue in current object
  1954.                                       ;   03h = Release resources only
  1955.                                       ;   04h = Release, then init and seek
  1956.             audtype  db               ; Type of audio compression to use
  1957.                                       ;   00h = Current/Default
  1958.                                       ;   01h = ADPCM 11.0K (music)
  1959.                                       ;   02h = ADPCM  5.5K (voice)
  1960.                                       ;   03h = ADPCM 22.0K (stereo music)
  1961.                                       ;   04h = ADPCM 22.0K (High Qual music)
  1962.                                       ;   60h = PCM
  1963.             intlevel db               ; Audio card interrupt level
  1964.             inpsrce  db               ; Audio card input source
  1965.                                       ;   00h = Microphone input - normal
  1966.                                       ;   01h = Line level input - left
  1967.                                       ;   02h = Line level input - right
  1968.                                       ;   03h = Line level input - both
  1969.                                       ;   04h = Microphone input - low
  1970.             piobase  dw               ; Audio card base address
  1971.             controls dw               ; Control changes requested
  1972.                                       ;   (Set bits individually)
  1973.                                       ;   01h = Master volume
  1974.                                       ;   02h = Track volume - 1
  1975.                                       ;   04h = Track volume - 2
  1976.                                       ;   08h = Channel Balance
  1977.                                       ;   10h = Set stop position
  1978.                                       ;   20h = Perform I/O
  1979.                                       ;   40h = Pause current operation
  1980.                                       ;   80h = Resume current operation
  1981.  
  1982.  
  1983.  
  1984.                                         4.  Control Data Structures  39
  1985.  
  1986.  
  1987.  
  1988.             oprparms dw               ; Operation parameters
  1989.                                       ;   (Set bits individually)
  1990.                                       ;   02h = Do not update audio object
  1991.                                       ;         totals during record operations
  1992.                                       ;   04h = PS/2 speaker output enabled
  1993.                                       ;   10h = Monitor, record pre-compression
  1994.                                       ;   20h = Monitor, recrd post-compression
  1995.                                       ;  200h = Cancel operation if process is
  1996.                                       ;         not in foreground
  1997.                                       ;  400h = Setup VOICE/MIDI DSP
  1998.                                       ;         environment if voice is started
  1999.                                       ;         first
  2000.             fileptr  dd               ; File Access Block pointer
  2001.             subtype  dw               ; FABO subtype of objects
  2002.             audstart dd               ; Start position for seek (milliseconds)
  2003.                                       ;   00000000h = Start of data
  2004.             audend   dd               ; End position for seek  (milliseconds)
  2005.                                       ;   00000000h = End of data
  2006.             bufflen  dd               ; I/O buffer length
  2007.             buffptr  dd               ; I/O buffer pointer
  2008.             emmhan   dw               ; Expanded memory manager handle
  2009.             emmcnt   dw               ; Expanded memory manager page count
  2010.             memid    dw               ; Memory type id
  2011.                                       ;   00h = not allocated
  2012.                                       ;   01h = main memory
  2013.                                       ;   02h = LIM memory
  2014.                      db 6 dup         ;   (reserved -- 00h)
  2015.             ctlparms db               ; Control parameters
  2016.                                       ;   (Set bits individually)
  2017.                                       ;   01h = Stop - Ignore other ctrls (on)
  2018.                                       ;         Stop - Honor pending ctrls(off)
  2019.                                       ;   02h = Purge control queue for this
  2020.                                       ;          channel before processing
  2021.                                       ;          new controls
  2022.                                       ;   04h = This call is being done from
  2023.                                       ;          within an interrupt service
  2024.                                       ;          in DOS.
  2025.                                       ;   08h = Pause/Resume all channels (on)
  2026.                                       ;         Pause/Resume only this ch (off)
  2027.    |                                  ;   10h = Restore previous controls
  2028.  
  2029.  
  2030.  
  2031.                                         4.  Control Data Structures  40
  2032.  
  2033.  
  2034.  
  2035.             masvol   db               ; Master volume level
  2036.    |                                  ;  ADPCM (0-100)   PCM (0-100)
  2037.             trkvol1  dw               ; Track volume level 1 (0 - 100)
  2038.             trkvol1s dd               ; Start position for trk vol1 change(ms)
  2039.             trkvol1e dd               ; End position for trk vo1l change (ms)
  2040.             trkvol2  dw               ; Track volume level 2 (0 - 100)
  2041.             trkvol2s dd               ; Start position for trk vol2 change(ms)
  2042.             trkvol2e dd               ; End position for trk vo12 change (ms)
  2043.             chnbal   db               ; Channel balance (pan) level  (100 - 0)
  2044.             outchan  db               ; Output channel pair for balance
  2045.                                       ;   0 = Channel Left/right
  2046.                                       ;   1 = Channel Right/Left
  2047.             chnbals  dd               ; Start position for chan bal change (ms)
  2048.             chnbale  dd               ; End position for channel bal change(ms)
  2049.             stoppos  dd               ; Position to stop operation (ms)
  2050.             iotime   dd               ; Length of audio read/write (ms)
  2051.                                       ;   00000000h = Maximum length
  2052.             acb2ptr  dd               ; ACB pointer of second track to process
  2053.                                       ;   00000000h = Single track
  2054.             listptr  dd               ; Ptr to list of start/stop positions
  2055.             dsp_path dd               ; Ptr to directory path for DSP code
  2056.    |        svrsptr  dd               ; Ptr to save/restore area for controls
  2057.    |        fmtptr   dd               ; Ptr to audio format data
  2058.    |        in_reser db 20 dup        ; Reserved area for input parm expansion
  2059.  
  2060.                                       ; *** OUTPUT PARAMETERS ***
  2061.             position dd               ; Current position in audio (ms)
  2062.             state    db               ; Current state of signal processor
  2063.                                       ;   00h = stopped
  2064.                                       ;   01h = playing
  2065.                                       ;   02h = recording
  2066.                                       ;   03h = stopping
  2067.             backrc   dw               ; Background process return code
  2068.             acb2rc   dw               ; Return code for second track operation
  2069.             timeleft dd               ; Time left before I/O necessary (ms)
  2070.             oupdates dw               ; Audio objects updated flag
  2071.                                       ;   (Set bits individually)
  2072.                                       ;   01h = AUDIO object changed
  2073.                                       ;   02h = VOLUME object changed
  2074.                                       ;   04h = ESCAPE object changed
  2075.             out_rese db 8 dup         ; Reserved area for output parm expansion
  2076.    |                 db 256 dup       ; AAPI work area
  2077.             acb      ends
  2078.  
  2079.      The parameters in the AAPI control block can have the following values:
  2080.  
  2081.      1.  CHANNEL - channel/track identifier
  2082.  
  2083.          This parameter selects  the channel on the signal  processor where the
  2084.          operation will be performed.
  2085.  
  2086.          ∙   0 - Channel A
  2087.  
  2088.  
  2089.                                         4.  Control Data Structures  41
  2090.  
  2091.  
  2092.  
  2093.          ∙   1 - Channel B
  2094.  
  2095.    |     ∙   255 -  The AAPI will select  and return available channel  in this
  2096.    |         field.
  2097.  
  2098.      2.  DSPMODE - Mode for audio signal processor
  2099.  
  2100.          ∙   1 - Initialize  and load, if not already  loaded, signal processor
  2101.              for play operations.
  2102.  
  2103.          ∙   2 - Initialize  and load, if not already  loaded, signal processor
  2104.              for record operations.
  2105.  
  2106.          ∙   3 - Initialize  and load, if not already  loaded, signal processor
  2107.              for monitor operations.
  2108.  
  2109.      3.  SEEKTYPE - Type of processing to do on the audio objects.
  2110.  
  2111.          ∙   0 - Initialize for audio objects  in passed FAB.  Seek to position
  2112.              requested in "AUDSTART".
  2113.  
  2114.          ∙   1  - Seek  to position  requested in  "AUDSTART" in  current audio
  2115.              object(s).
  2116.  
  2117.          ∙   2 - Continue in the current audio object(s) with no seek.
  2118.  
  2119.          ∙   3 -  Release audio  object resources allocated  by AAPI.  No other
  2120.              processing is done.  Assumes FAB information is still correct.
  2121.  
  2122.          ∙   4 - End processing on  current audio object(s), and initialize for
  2123.              audio  objects  in passed  FAB.   Seek  to position  requested  in
  2124.              "AUDSTART".   Assumes that  previous  FAB is  still allocated  and
  2125.              valid.
  2126.  
  2127.      4.  AUDTYPE  - Type of compression method  to use when recording, or moni-
  2128.          toring.
  2129.  
  2130.          ∙   00h - Use method in current object, or default for new object
  2131.  
  2132.          ∙   01h - Use ADPCM/11K  algorithm (mono music)
  2133.  
  2134.          ∙   02h - Use ADPCM/5.5K algorithm (mono voice)
  2135.  
  2136.          ∙   03h - Use ADPCM/22K  algorithm (stereo music)
  2137.  
  2138.          ∙   04h - Use ADPCM/22K  algorithm (mono high quality music)
  2139.  
  2140.    |     ∙   60h - Use PCM algorithm
  2141.  
  2142.      5.  INTLEVEL - The  hardware interrupt level the audio card  has been con-
  2143.          figured to use.
  2144.  
  2145.      6.  INPSRCE  - The input source the audio card should consider active.
  2146.  
  2147.  
  2148.                                         4.  Control Data Structures  42
  2149.  
  2150.  
  2151.  
  2152.          ∙   00h - Microphone input - normal gain
  2153.  
  2154.          ∙   01h - Line level input - left channel only
  2155.  
  2156.          ∙   02h - Line level input - right channel only
  2157.  
  2158.          ∙   03h - Line level input - both channels
  2159.  
  2160.          ∙   04h - Microphone input - low gain
  2161.  
  2162.      7.  PIOBASE  - The starting address of a block of eight I/O addresses that
  2163.          the audio card has been configured to use.
  2164.  
  2165.      8.  CONTROLS - flag indicating control changes to execute
  2166.  
  2167.          ∙   01h - Set the master volume based on caller's input
  2168.  
  2169.          ∙   02h - Set the track volume based on caller's input
  2170.  
  2171.          ∙   04h - Set the track volume (at a different position)
  2172.  
  2173.          ∙   08h - Set the channel balance based on caller's input
  2174.  
  2175.          ∙   10h - Set the position in the audio to stop current operation
  2176.  
  2177.          ∙   20h - Refresh the I/O buffer if necessary
  2178.  
  2179.          ∙   40h  - Pause  the current  operation until  a "resume"  control is
  2180.              requested.
  2181.  
  2182.          ∙   80h - Resume a "paused" operation.
  2183.  
  2184.      9.  OPRPARMS - flag indicating parameters for DSP operations.
  2185.  
  2186.          ∙   02h - Do not update audio  and volume object segment totals during
  2187.              record operations.  The variable sections of these objects will be
  2188.              updated normally but  fields in the header will not  be changed by
  2189.              the AAPI.
  2190.  
  2191.          ∙   04h -  Enables the PS/2  speaker for  output from the  audio card.
  2192.              This has  no effect on  the other output sources  (line, speaker).
  2193.              This flag is ignored if not running on a PS/2 system.
  2194.  
  2195.          ∙   10h  - Enables  pass  through  of any  input  to  the card,  while
  2196.              recording, to the output channels, before any compression is done.
  2197.  
  2198.          ∙   20h  - Enables  pass  through  of any  input  to  the card,  while
  2199.              recording,  to the  output channels,  after compression  has taken
  2200.              place.
  2201.  
  2202.          ∙   200h - If the process that the Audio API is running in is switched
  2203.              to the background (user task switch for example) the current oper-
  2204.              ation  will be  cancelled and  an error  will be  returned to  the
  2205.              caller (OS2 only).
  2206.  
  2207.  
  2208.                                         4.  Control Data Structures  43
  2209.  
  2210.  
  2211.  
  2212.          ∙   400h  - If  playing  VOICE  mode audio  is  requested first,  then
  2213.              setting this flag will cause the DSP code environment to be set up
  2214.              to play  VOICE and MIDI  simultaneously.  If  the flag is  not set
  2215.              then the  DSP environment will be  set up for VOICE  and (VOICE or
  2216.              MUSIC).
  2217.  
  2218.      10. FILEPTR - A  pointer to a File  Access Block for an  audio file.  This
  2219.          pointer allows access, using FABOs, to the various audio objects.
  2220.  
  2221.      11. SUBTYPE  - The  sub-type of  the objects  to operate  on.  This  would
  2222.          normally be zero if only one track of audio data is in the file.
  2223.  
  2224.      12. AUDSTART -  The start position in  milliseconds of where to  begin the
  2225.          requested operation in the audio track.   A value of zero will be con-
  2226.          sidered the physical start of the track.
  2227.  
  2228.      13. AUDEND  - The  end  position  in milliseconds  of  where  to stop  the
  2229.          requested operation in  the audio track. A value of  zero will be con-
  2230.          sidered the physical end of the track.
  2231.  
  2232.      14. BUFFLEN - The length of the caller passed I/O buffer (buffptr), or the
  2233.          length that the AAPI should allocate from main memory.
  2234.  
  2235.      15. BUFFPTR - A pointer  to a buffer to be used for  I/O operations by the
  2236.          AAPI.
  2237.  
  2238.      16. EMMHAN  - The  extended memory  manager handle  to use  if the  caller
  2239.          passes a LIM memory pointer (BUFFPTR).
  2240.  
  2241.      17. EMMCNT - The  extended memory manager page count to  use if the caller
  2242.          passes a LIM memory pointer (BUFFPTR).
  2243.  
  2244.      18. MEMID -  The type of memory passed by the caller in "BUFFPTR".
  2245.  
  2246.          ∙   00h - not allocated
  2247.  
  2248.          ∙   01h - main memory
  2249.  
  2250.          ∙   02h - LIM memory
  2251.  
  2252.          ∙   03h - Device
  2253.  
  2254.      19. RESERVED - A reserved area  for additional information about the call-
  2255.          er's passed memory area.
  2256.  
  2257.      20. CTLPARMS - flag indicating parameters for control requests
  2258.  
  2259.          ∙   01h  - Stop  request will  ignore  other controls  in progress  or
  2260.              pending and execute at the time  requested in STOPPOS.  If the bit
  2261.              is  off  the  stop  will  not execute  until  the  time  requested
  2262.              (STOPPOS) and all other controls  in progress or pending have com-
  2263.              pleted.
  2264.  
  2265.  
  2266.                                         4.  Control Data Structures  44
  2267.  
  2268.  
  2269.  
  2270.          ∙   02h - Purge this channel's control queue before processing any new
  2271.              controls requested in CONTROLS.
  2272.  
  2273.          ∙   04h -  This call is  being made  from within an  interrupt service
  2274.              routine in  DOS. The call will  not be processed if  DOS is "busy"
  2275.              and not re-entrant.
  2276.  
  2277.          ∙   08h - Based on what "CONTROLS"  value is set (pause or resume) the
  2278.              current operation  for all channels  will be paused or  resumed if
  2279.              this flag is  set.  If the flag  is not set then  only the current
  2280.              channel will be affected.
  2281.  
  2282.    |     ∙   10h -  Requests that any  previously saved control  information be
  2283.    |         restored.  This is  used to restart a play or  record operation in
  2284.    |         the same  position with the same  control settings as when  it was
  2285.    |         stopped.
  2286.  
  2287.      21. MASVOL -  For ADPCM, a value  from zero to one  hundred specifying the
  2288.          percentage  of maximum  volume that  can be  used at  this time.   For
  2289.          example,  a setting  of 70  would mean  that only  70% of  the maximum
  2290.    |     volume  the  hardware supports  will  be  allowed.  When  playing  and
  2291.    |     recording PCM the upper limit is 120%.  Setting values over 100% cause
  2292.    |     the volume level  of the track being recorded or  played to be boosted
  2293.    |     above its original recorded level.
  2294.  
  2295.      22. TRKVOL1 - A  value from zero to one hundred  specifying the percentage
  2296.          of  the maximum  volume  to be  used while  playing  this track.   The
  2297.          maximum volume allowed  is based on what the hardware  can support and
  2298.          the current setting of the master volume (MASVOL) control.
  2299.  
  2300.      23. TRKVOL1S - The start position in milliseconds of where to begin fading
  2301.          the track volume level (TRKVOL1) in the audio track.
  2302.  
  2303.      24. TRKVOL1E - The  end position in milliseconds of where  to complete the
  2304.          track volume  level change in  the audio track.   Subtracting TRKVOL1S
  2305.          from TRKVOL1E will  give the amount of time in  milliseconds that will
  2306.          be used  while fading  from the  current track  volume setting  to the
  2307.          requested volume setting (TRKVOL1).
  2308.  
  2309.      25. TRKVOL2 - A  value from zero to one hundred  specifying the percentage
  2310.          of  the maximum  volume  to be  used while  playing  this track.   The
  2311.          maximum volume allowed  is based on what the hardware  can support and
  2312.          the current setting of the master volume (MASVOL) control.
  2313.  
  2314.      26. TRKVOL2S - The start position in milliseconds of where to begin fading
  2315.          the track volume level (TRKVOL2) in the audio track.
  2316.  
  2317.      27. TRKVOL2E - The  end position in milliseconds of where  to complete the
  2318.          track volume  level change in  the audio track.   Subtracting TRKVOL2S
  2319.          from TRKVOL2E will  give the amount of time in  milliseconds that will
  2320.          be used  while fading  from the  current track  volume setting  to the
  2321.          requested volume setting (TRKVOL2).
  2322.  
  2323.  
  2324.                                         4.  Control Data Structures  45
  2325.  
  2326.  
  2327.  
  2328.      28. CHNBAL  - A  value from zero to one hundred  specifying the percentage
  2329.          of the  signal balance that  is sent to the  first channel in  the two
  2330.          channels named in "OUTCHN".  The second channel receives the remainder
  2331.          of the signal.
  2332.  
  2333.      29. OUTCHAN - A value that indicates the pair of channels that "CHNBAL" is
  2334.          dividing the signal between.
  2335.  
  2336.          ∙   00h - Left  channel(signal % in CHNBAL),  Right channel (remaining
  2337.              %)
  2338.  
  2339.          ∙   01h - Right channel (signal  % in CHNBAL), Left channel (remaining
  2340.              %)
  2341.  
  2342.      30. CHNBALS -  The start position  in milliseconds  in the audio  track of
  2343.          where  to  begin  fading  from  the current  balance  setting  to  the
  2344.          requested balance setting (CHNBAL).
  2345.  
  2346.      31. CHNBALE - The end position in milliseconds in the audio track of where
  2347.          to complete fading  from the current balance setting  to the requested
  2348.          balance setting (CHNBAL).
  2349.  
  2350.      32. STOPPOS - The position in milliseconds  in the audio track of where to
  2351.          stop the current operation.
  2352.  
  2353.      33. IOTIME - The amount of audio data (in milliseconds) that the caller is
  2354.          requesting to be  read into or written from the  I/O buffer (BUFFPTR).
  2355.          A zero value will cause the maximum amount of data possible to be read
  2356.          or written.
  2357.  
  2358.      34. ACB2PTR -  A pointer to  a second Audio  Control Block. The  AAPI will
  2359.          attempt to perform the requested operations in both ACBs as simultane-
  2360.          ously as possible.   This field allows two channel play  and dub oper-
  2361.          ations to be done  with one call.  The return code  for the second ACB
  2362.          is in the output field "ACB2RC".
  2363.  
  2364.      35. LISTPTR - A  pointer to a structure (linked list)  of start/stop posi-
  2365.          tions to  use during  play operations.   This list  is used  after the
  2366.          position in "AUDEND" is reached.
  2367.  
  2368.      36. DSP_PATH -  A pointer to  a directory path to  use to find  the signal
  2369.          processor code files.   If this field is zero then  the current direc-
  2370.          tory is used.
  2371.  
  2372.    | 37. SVRSPTR  - A  pointer to a save/restore  area to be used  to store the
  2373.    |     current control state (volume, balance, etc).
  2374.    |
  2375.    | 38. FMTPTR - A pointer to a audio format area containing information about
  2376.    |     the type of audio compression being performed.
  2377.  
  2378.      39. IN_RESERVE - A 20 byte area reserved for expansion of the input param-
  2379.          eters.
  2380.  
  2381.  
  2382.                                         4.  Control Data Structures  46
  2383.  
  2384.  
  2385.  
  2386.      40. POSITION - The  current position (in milliseconds) in  the audio data.
  2387.          This field is updated at .1  second intervals by the AAPI during asyn-
  2388.          chronous audio operations.
  2389.  
  2390.      41. STATE - The current state of the signal processor.
  2391.  
  2392.          ∙   00h - Stopped.  The signal processor is halted.
  2393.  
  2394.          ∙   01h - Playing.  The signal processor is playing.
  2395.  
  2396.          ∙   02h - Recording. The signal processor is recording.
  2397.  
  2398.          ∙   03h - Stopping.  The signal  processor has received a stop request
  2399.              but is completing an operation before stopping.
  2400.  
  2401.      42. BACKRC - Return  code set by the AAPI when  running in the background.
  2402.          After an  operation has been  started, and  the AAPI detects  an error
  2403.          (device  full for  example), the  operation will  be stopped  and this
  2404.          field will contain the error code.
  2405.  
  2406.      43. ACB2RC - The return code from a second ACB passed in field "ACB2PTR".
  2407.  
  2408.      44. TIMELEFT - Time remaining before the AAPI begins asynchronous I/O.
  2409.  
  2410.      45. OUPDATES - Audio objects updated flag
  2411.  
  2412.          ∙   01h = AUDIO object changed
  2413.  
  2414.          ∙   02h = VOLUME object changed
  2415.  
  2416.          ∙   04h = ESCAPE object changed
  2417.  
  2418.      46. OUT_RESERVE - An eight byte area  reserved for expansion of the output
  2419.          parameters.
  2420.  
  2421.      47. AAPIWORK - A reserved area for the AAPI work area.
  2422.  
  2423.    | 4.4  AUDIO FORMAT STRUCTURE  (AFMT)
  2424.      ___________________________________
  2425.  
  2426.    | The AFMT  is the structure used  to pass additional information  about the
  2427.    | audio type.  Currently it is only used with the PCM audio type.  The field
  2428.    | values marked below with (W) are valid for RIFF WAVE files.  If the caller
  2429.    | uses other values (marked with (i)) that are valid in the AAPI but not yet
  2430.    | defined for  the RIFF WAVE format  then the file  will be saved as  a RIFF
  2431.    | file but with a form type of "ibmw" instead of WAVE.
  2432.  
  2433.  
  2434.                                         4.  Control Data Structures  47
  2435.  
  2436.  
  2437.  
  2438.    |   ; ** Audio Format Structure
  2439.    |   ; _________________________
  2440.    |        afmt     struc
  2441.    |                                  ;
  2442.    |        format               dw   ; Format of audio data
  2443.    |                                  ;   01h = Linear PCM     (W)
  2444.    |                                  ;   02h = mu-law         (W)
  2445.    |                                  ;   03h = A-law          (W)
  2446.    |        samples_per_second   dd   ; Sample rate in hertz
  2447.    |                                  ;   8000, 11025, 22050, 44100  (W)
  2448.    |        bits_per_sample      dw   ; Sample width in bits
  2449.    |                                  ;   8 or 16              (W)
  2450.    |        channels             dw   ; Number of channels
  2451.    |                                  ;   1 or 2               (W)
  2452.    |        sample_number_format dw   ; Format of sample
  2453.    |                                  ;   02h = Unsigned       (W)
  2454.    |                                  ;   (8 bits per sample)
  2455.    |                                  ;   01h = Signed
  2456.    |                                  ;   00h = 2's complement (W)
  2457.    |                                  ;   (16 bits per sample)
  2458.    |        dither_percent       dw   ; Amount of dither in % of
  2459.    |                                  ;  one bit (Rec/monitor only)
  2460.    |                                  ;   21h = Recommended value
  2461.    |        format_flag          dw   ; General flag
  2462.    |                                  ;   01h - Source Mix on
  2463.    |        reserved      db 20 dup   ; Reserved for expansion
  2464.    |        afmt     ends
  2465.    |
  2466.    | See Appendix C, "Additional Information  on PCM Support" on  page 71 for a
  2467.    | detailed explanation of the above fields.
  2468.  
  2469.  
  2470.                                         4.  Control Data Structures  48
  2471.  
  2472.  
  2473.  
  2474.      5.  USAGE EXAMPLES
  2475.      __________________
  2476.  
  2477.  
  2478.      5.1  CHECK AUDIO HARDWARE AND SOFTWARE CONFIGURATION
  2479.      ____________________________________________________
  2480.  
  2481.      1.  Verify that signal processor microcode file  is located in a path that
  2482.          can be found when the application is executed.
  2483.  
  2484.      2.  Allocate an Audio Device Control Block to pass to the AAPI.
  2485.  
  2486.      3.  Call AUD_CFIG passing a pointer to the ADCB.
  2487.  
  2488.      4.  Check return code
  2489.  
  2490.          ∙   If 0,  this system has an  available audio device.  The  ADCB con-
  2491.              tains the hardware configuration information.
  2492.  
  2493.          ∙   If 3224, no audio device was found.
  2494.  
  2495.          ∙   If 3225, an audio device was found, but interrupts are disabled.
  2496.  
  2497.          ∙   If 3226, the system has an  audio device, but the device driver is
  2498.              not responding.   The OS/2 error code is available in the ADCB.
  2499.  
  2500.      5.2  PLAY (SINGLE CHANNEL)
  2501.      __________________________
  2502.  
  2503.    | 1.  Determine type of audio file (FAB_TYPE).
  2504.  
  2505.      2.  Allocate and initialize  FAB/FABOs and open the  audio file (FAB_OPEN,
  2506.          FAB_ROPN, or application file handling code)
  2507.  
  2508.      3.  Allocate an I/O buffer and an ACB to pass to the AAPI.
  2509.  
  2510.      4.  Call AUD_INIT passing the ACB pointer.
  2511.  
  2512.      5.  Call AUD_SET  with the  appropriate parameters.  These  parameters can
  2513.          include setting volume fade-in and  fade-out controls and the position
  2514.          in the audio to stop playing.
  2515.  
  2516.      6.  Call AUD_STRT when ready to start playing.
  2517.  
  2518.          Monitor the following  output fields in the ACB which  will be updated
  2519.          at .1 second intervals:
  2520.  
  2521.          ∙   POSITION - Current position in audio.
  2522.  
  2523.          ∙   TIMELEFT - Time left before AAPI will begin doing asynchronous I/O
  2524.              to refill the audio buffers.
  2525.  
  2526.      7.  Call AUD_CTRL*  as many  times as necessary  to change  audio controls
  2527.          and/or to request that I/O be performed to refill the audio buffers.
  2528.  
  2529.  
  2530.                                                  5.  Usage Examples  49
  2531.  
  2532.  
  2533.  
  2534.      8.  Call AUD_SET to continue or start  a new operation or AUD_TERM to ter-
  2535.          minate audio processing.  If AUD_TERM is called all audio objects that
  2536.          were not already open before the AUD_INIT call will be closed.
  2537.  
  2538.      *  Note: Audio  control requests  can  be made  on all  AAPI calls  except
  2539.      AUD_INIT and AUD_TERM by setting the "CONTROLS" parameter in the ACB.
  2540.  
  2541.      5.3  RECORD/MONITOR
  2542.      ___________________
  2543.  
  2544.    | 1.  Determine type of audio file (FAB_TYPE).
  2545.  
  2546.      2.  Allocate and initialize  FAB/FABOs and open the  audio file (FAB_OPEN,
  2547.          FAB_ROPN or application file handling code)
  2548.  
  2549.      3.  Allocate an I/O buffer and an ACB to pass to the AAPI.
  2550.  
  2551.      4.  Call AUD_INIT passing the ACB pointer.
  2552.  
  2553.      5.  Call AUD_SET with the appropriate parameters.
  2554.  
  2555.      6.  Call AUD_STRT when ready to start recording.
  2556.  
  2557.          Monitor the following  output fields in the ACB which  will be updated
  2558.          at .1 second intervals:
  2559.  
  2560.          ∙   POSITION - Current position in audio.
  2561.  
  2562.          ∙   TIMELEFT - Time left before AAPI will begin doing asynchronous I/O
  2563.              to flush the audio buffers.
  2564.  
  2565.      7.  Call AUD_CTRL as  many times as necessary to request  that I/O be per-
  2566.          formed to  flush the  audio buffers or  to set the  stop point  in the
  2567.          audio.
  2568.  
  2569.      8.  Call AUD_SET to continue or start  a new operation or AUD_TERM to ter-
  2570.          minate audio processing.  If AUD_TERM is called all audio objects that
  2571.          were not already open before the AUD_INIT call will be closed.
  2572.  
  2573.      5.4  PLAY (TWO CHANNEL)
  2574.      _______________________
  2575.  
  2576.      Method 1  - Use the single  channel example above for  both channels.  The
  2577.      caller must do a separate call for each channel for all requests.
  2578.  
  2579.      Method 2 - Pass a secondary ACB
  2580.  
  2581.    | 1.  Determine type of audio file for each channel (FAB_TYPE).
  2582.  
  2583.      2.  Allocate a  FAB and open an  audio file (FAB_OPEN, FAB_ROPN)  for each
  2584.          channel.
  2585.  
  2586.      3.  Allocate an I/O buffer and an ACB for each channel.
  2587.  
  2588.  
  2589.                                                  5.  Usage Examples  50
  2590.  
  2591.  
  2592.  
  2593.      4.  Call AUD_INIT  passing the ACB pointer  and the second ACB  pointer in
  2594.          ACB2PTR.  Both ACBs will be initialized.
  2595.  
  2596.      5.  Set the appropriate parameters in both ACBs and call AUD_SET.
  2597.  
  2598.      6.  Call AUD_STRT when ready to start playing.
  2599.  
  2600.          Monitor  the following  output  fields  in the  ACB(s)  which will  be
  2601.          updated at .1 second intervals:
  2602.  
  2603.          ∙   POSITION - Current position in audio.
  2604.  
  2605.          ∙   TIMELEFT - Time left before AAPI will begin doing asynchronous I/O
  2606.              to refill the audio buffers.
  2607.  
  2608.      7.  Call AUD_CTRL*  as many  times as necessary  to change  audio controls
  2609.          and/or to request that I/O be performed to refill the audio buffers.
  2610.  
  2611.      8.  Call AUD_SET to continue or start  a new operation or AUD_TERM to ter-
  2612.          minate audio processing.  If AUD_TERM is called all audio objects that
  2613.          were not already open before the AUD_INIT call will be closed.
  2614.  
  2615.      *  Note: Audio  control requests  can  be made  on all  AAPI calls  except
  2616.      AUD_INIT and AUD_TERM by setting the "CONTROLS" parameter in the ACB.
  2617.  
  2618.  
  2619.                                                  5.  Usage Examples  51
  2620.  
  2621.  
  2622.  
  2623.      6.  AVC AUDIO FILE FORMAT
  2624.      _________________________
  2625.  
  2626.  
  2627.      6.1  AUDIO FILE OVERVIEW
  2628.      ________________________
  2629.  
  2630.      The following section provides an overview  of the AVC file structure that
  2631.      is used  by the AAPI.  Detailed  descriptions of the data  structures that
  2632.      make  up  these files  is  presented  in  6.2, "File Data  Structures"  on
  2633.      page 55.
  2634.  
  2635.      6.1.1  AUDIO FILE TYPES
  2636.  
  2637.      There are  two types of  files associated with a  piece of AVC  audio.  An
  2638.      "AUDIO" file and an "ESCAPE" file.  Together, these files make up a single
  2639.      entity that can be created,  opened, and manipulated.  This document, when
  2640.      discussing an "audio file" will always mean the "AUDIO" file.  When refer-
  2641.      ring to the "ESCAPE" file, "escape file" will always be used.
  2642.  
  2643.      6.1.1.1  "AUDIO" File
  2644.  
  2645.      The "AUDIO"  file contains general  information about the file  itself and
  2646.      sub-components called "objects".   The file contains a header  and a vari-
  2647.      able length internal directory locating  the objects.  The header contains
  2648.      information  necessary to  verify  that  it is  an  audio  file, read  the
  2649.      internal  directory,  and recreate  external  directories  to the  objects
  2650.      within the file.  Each directory entry identifies an object, its size, and
  2651.      its location within the file.
  2652.  
  2653.      6.1.1.2  "ESCAPE" FILE
  2654.  
  2655.      The "ESCAPE"  file contains digitized  audio data.  All  information about
  2656.      the data and how to access it are contained in objects in the audio file.
  2657.  
  2658.      6.1.2  AUDIO OBJECT TYPES
  2659.  
  2660.      Each object has  a distinct type code.  The type  code identifies its par-
  2661.      ticular format.  An object can also be further distinguished by a sub-type
  2662.      field which indicates further differences  as to usages by an application.
  2663.      The sub-type field also distinguishes between multiple objects of the same
  2664.      type in the same file.
  2665.  
  2666.      Each object  consists of a  header and data  section.  The header  has the
  2667.      same data structure  for all objects of the same  type and provides suffi-
  2668.      cient information to process the data section.
  2669.  
  2670.      An audio file does not necessarily  contain all objects, only the "Audio",
  2671.      "Escape", and  "Volume" objects are  required.  The objects may  appear in
  2672.      any order in the file.
  2673.  
  2674.  
  2675.                                           6.  AVC Audio File Format  52
  2676.  
  2677.  
  2678.  
  2679.  
  2680.      There are  five types  of audio  objects.  Figure 1  on page 54  shows the
  2681.      structure  and relationships  of the  audio  files and  objects.  A  brief
  2682.      description of each  object type and how  it is used by the  AAPI is given
  2683.      below.
  2684.  
  2685.      "AUDIO" Object
  2686.  
  2687.      The "AUDIO" object is a  standard object that contains general information
  2688.      about, and an index to, a collection of digitized audio data.
  2689.  
  2690.      The "unique  to object" section  includes the following  information about
  2691.      the audio data:
  2692.  
  2693.      ∙   Length of data (milliseconds and bytes)
  2694.  
  2695.      ∙   Encoding scheme
  2696.  
  2697.      ∙   Indexing scheme
  2698.  
  2699.      The "variable section" includes the  following information about the audio
  2700.      data:
  2701.  
  2702.      ∙   Array  of indexes  into audio  data.  Each  index points  to an  audio
  2703.          segment.  An audio segment is an addressable unit of audio.
  2704.  
  2705.      The AAPI uses this  object to locate and read audio  data for playing, and
  2706.      updates this object during record.
  2707.  
  2708.      "AUDVOL" Object
  2709.  
  2710.      The "AUDVOL" object is a standard object that contains volume information.
  2711.      This volume information corresponds to  the indexed segment information in
  2712.      the  "AUDIO" object.   Each  indexed segment  has  a corresponding  volume
  2713.      entry.
  2714.  
  2715.      The "unique  to object" section  includes the following  information about
  2716.      the audio data:
  2717.  
  2718.      ∙   Number of volume data entries.
  2719.  
  2720.      The "variable section" includes the  following information about the audio
  2721.      data:
  2722.  
  2723.      ∙   Volume information about one segment of audio data
  2724.  
  2725.      The AAPI updates this object during record operations.
  2726.  
  2727.      "ESCAPE" Object
  2728.  
  2729.      The "ESCAPE"  object is a  special type of  object that has  normal header
  2730.      sections but no  variable section.  The "ESCAPE" object points  to a sepa-
  2731.      rate "escape"  file.  The  contents of  this file  is the  digitized audio
  2732.      data.
  2733.  
  2734.  
  2735.                                           6.  AVC Audio File Format  53
  2736.  
  2737.  
  2738.  
  2739.      ┌────────────────────────────────────────────────────────────────────────┐
  2740.      │                                                                        │
  2741.      │     AUDIO File                                                         │
  2742.      │     │                                                                  │
  2743.      │     │                                                                  │
  2744.      │     │ "AUDIO" Object                                                   │
  2745.      │     │                                                                  │
  2746.      │     │    General information about audio data                          │
  2747.      │     │    Index to individual audio segments                            │
  2748.      │     │      (one index entry for each segment)                          │
  2749.      │     │                                                                  │
  2750.      │     │ "AUDVOL" Object                                                  │
  2751.      │     │                                                                  │
  2752.      │     │    Volume data for audio segments                                │
  2753.      │     │      (one volume entry for each audio segment)                   │
  2754.      │     │                                                                  │
  2755.      │     │ "ESCAPE" Object                                                  │
  2756.      │     │                                                                  │
  2757.      │     │    Information about separate "escape" file                      │
  2758.      │     │                                                                  │
  2759.      │     │ "AUDPNTS" Object                                                 │
  2760.      │     │                                                                  │
  2761.      │     │    Application program information                               │
  2762.      │     │                                                                  │
  2763.      │     │ "AUDLABL" Object                                                 │
  2764.      │     │                                                                  │
  2765.      │     │    Application program information                               │
  2766.      │     │                                                                  │
  2767.      │     End of AUDIO File                                                  │
  2768.      │                                                                        │
  2769.      │                                                                        │
  2770.      │                                                                        │
  2771.      │     ESCAPE File                                                        │
  2772.      │     │                                                                  │
  2773.      │     │ Digital audio data segments                                      │
  2774.      │     │                                                                  │
  2775.      │     End of ESCAPE File                                                 │
  2776.      │                                                                        │
  2777.      └────────────────────────────────────────────────────────────────────────┘
  2778.  
  2779.  
  2780.      Figure 1.   Audio Files and Objects
  2781.  
  2782.      The "unique  to object" section  includes the following  information about
  2783.      the audio data:
  2784.  
  2785.      ∙   "Escape" file access information
  2786.  
  2787.      The "variable section" includes the following information:
  2788.  
  2789.      ∙   None
  2790.  
  2791.      The  AAPI reads  this data  during play,  and updates  this object  during
  2792.      record.
  2793.  
  2794.  
  2795.                                           6.  AVC Audio File Format  54
  2796.  
  2797.  
  2798.  
  2799.      "AUDPNTS" Object
  2800.  
  2801.      The "AUDPNTS" object is a standard object that contains application infor-
  2802.      mation about the audio data.
  2803.  
  2804.      The "unique  to object" section  includes the following  information about
  2805.      specific points in the audio.
  2806.  
  2807.      ∙   Number of points listed in variable section
  2808.  
  2809.      The "variable section" includes the  following information about the audio
  2810.      data:
  2811.  
  2812.      ∙   Point position (milliseconds)
  2813.  
  2814.      ∙   Application information
  2815.  
  2816.      The AAPI does not  use this object but will allocate  and initialize it if
  2817.      requested.
  2818.  
  2819.      "AUDLABL" Object
  2820.  
  2821.      The "AUDLABL"  object is a standard  object that contains a  subset of the
  2822.      information in "AUDPNTS" object.
  2823.  
  2824.      The "unique  to object" section  includes the following  information about
  2825.      specific points in the audio.
  2826.  
  2827.      ∙   Number of points listed in variable section
  2828.  
  2829.      The "variable section" includes the  following information about the audio
  2830.      data:
  2831.  
  2832.      ∙   Point position (milliseconds)
  2833.  
  2834.      ∙   Application information
  2835.  
  2836.      The AAPI does not  use this object but will allocate  and initialize it if
  2837.      requested.
  2838.  
  2839.      6.2  FILE DATA STRUCTURES
  2840.      _________________________
  2841.  
  2842.      The following section provides detailed information on the data structures
  2843.      needed to  create and manipulate audio  files both on disk  and in memory.
  2844.      The AAPI  provides functions to  perform high level file  processing using
  2845.      these structures, but  the caller must still have an  understanding of the
  2846.      structures to do more complicated operations.  The caller need not use the
  2847.      AAPI file functions  at all, replacing them  with his own, as  long as the
  2848.      file data is kept in the correct format when presented to the AAPI.
  2849.  
  2850.  
  2851.                                           6.  AVC Audio File Format  55
  2852.  
  2853.  
  2854.  
  2855.      6.2.1  DIRECTORY CONTROL BLOCK
  2856.  
  2857.      This is a representation of the organization of an audio file on disk.  It
  2858.      consists of a header and an array of directory entries, each entry repres-
  2859.      enting an object in the file.
  2860.  
  2861.      The overall directory control block is:
  2862.  
  2863.             Directory Control Block
  2864.               Directory header
  2865.               First directory entry
  2866.               Next directory entry
  2867.                       .
  2868.                       .
  2869.               Last directory entry
  2870.             End of Directory Control Block
  2871.  
  2872.        ; ** Directory Control Block Header **
  2873.        ; _________________________
  2874.             dcbh     struc
  2875.                                       ;
  2876.             sig       db 8  dup       ; Signature and null terminator
  2877.             vers      dw              ; Version/Modification
  2878.             ftype     dw              ; File type
  2879.             eod       dd              ; Total bytes of data
  2880.             reserve1  dd              ; Reserved - compatibility
  2881.             ents      dw              ; Number of directory entries
  2882.             activ     dw              ; Number of active directory entries
  2883.             reserve2  db 12  dup      ; Reserved - compatibility
  2884.             name      db 64           ; ASCII-z reference code
  2885.             reserve3  db 36  dup      ; Reserved - compatibility
  2886.             reserve4  db 21  dup      ; Reserved - expansion
  2887.             reserve5  db  3  dup      ; Reserved - compatibility
  2888.             dcbh     ends
  2889.  
  2890.      The fields in  the Directory Control Block Header are  defined below.  Any
  2891.      field where specific values  are not given should be set  to zero for com-
  2892.      patibility with other  products.  Likewise, any reserved  fields should be
  2893.      set to zero.
  2894.  
  2895.      1.  SIG - A standard literal string  identifying the file for a particular
  2896.          product.  The signature for the AVC product is "+A+V+C+".
  2897.  
  2898.      2.  VERS -  Indicates the  level of the  file, permitting  recognition and
  2899.          processing of down-level files.
  2900.  
  2901.      3.  FTYPE  -  A code  to characterize  the file  in general  terms.  Audio
  2902.          files shoud be set to 0x0500.
  2903.  
  2904.      4.  EOD - Total bytes is the data area spanned by the file from the begin-
  2905.          ning of the  directory to the end of the  physically last object.  The
  2906.          offset following the  end of this last object is  available for writes
  2907.          of new or updated objects.
  2908.  
  2909.  
  2910.                                           6.  AVC Audio File Format  56
  2911.  
  2912.  
  2913.  
  2914.      5.  RESERVE1 - Reserved for product compatibility.
  2915.  
  2916.      6.  ENTS  - Number  of directory  entries  is a  count enabling  functions
  2917.          opening a  file to allocate  the proper amount  of memory to  hold the
  2918.          entire directory.   Null directory  entries, if  any, are  included in
  2919.          this count.
  2920.  
  2921.      7.  ACTIV - Number of active directory  entries is a count of the non-null
  2922.          entries. Active entries physically appear first in the directory.
  2923.  
  2924.      8.  RESERVE2 - Reserved for product compatibility.
  2925.  
  2926.      9.  NAME - Fully-qualified file name.
  2927.  
  2928.      10. RESERVE3 - Reserved for product compatibility.
  2929.  
  2930.      11. RESERVE4 - A reserved area for future expansion.
  2931.  
  2932.      12. RESERVE5 - Reserved for product compatibility.
  2933.  
  2934.        ; ** Directory Control Block Entry **
  2935.        ; _________________________
  2936.             dcbe     struc
  2937.                                       ;
  2938.             type      dw              ; Object type code
  2939.             subtype   dw              ; Object subtype code
  2940.             reserve1  db  2  dup      ; Reserved - compatibility
  2941.             sizh      dw              ; Size of object header in file
  2942.             sizv      dd              ; Size of data section in file
  2943.             size      dd              ; Size of object in file
  2944.             reserve2  db  4  dup      ; Reserved - compatibility
  2945.             offset    dd              ; Objects offset in file
  2946.             reserve3  db  8  dup      ; Reserved- expansion
  2947.             dcbe     ends
  2948.  
  2949.      The fields  in the Directory Control  Block Entry are defined  below.  Any
  2950.      field where specific values  are not given should be set  to zero for com-
  2951.      patibility with other  products.  Likewise, any reserved  fields should be
  2952.      set to zero.
  2953.  
  2954.      1.  TYPE - Classifies the object and  indicates the layout of the object's
  2955.          header.  The object type and sub-type codes for a null entry are 0000.
  2956.          See the FAB type field for valid audio object types.
  2957.  
  2958.      2.  SUBTYPE - See the FAB subtype field for valid audio object subtypes.
  2959.  
  2960.      3.  RESERVE1 - A reserved area for product compatibility.
  2961.  
  2962.      4.  SIZH - Number of data bytes in the file for the header section.
  2963.  
  2964.      5.  SIZV  - Number of data bytes in the file for the data section.
  2965.  
  2966.      6.  SIZE - Total number of bytes for both the header and data section.
  2967.  
  2968.  
  2969.                                           6.  AVC Audio File Format  57
  2970.  
  2971.  
  2972.  
  2973.      7.  RESERVE2 - A reserved area for product compatibility.
  2974.  
  2975.      8.  OFFSET - The object's offset from the start of the file.
  2976.  
  2977.      9.  RESERVE3 - A reserved area for future expansion.
  2978.  
  2979.  
  2980.                                           6.  AVC Audio File Format  58
  2981.  
  2982.  
  2983.  
  2984.      6.2.2  FILE ACCESS BLOCK (FAB)
  2985.  
  2986.      This is the  representation of an audio  file in memory.  It  has a header
  2987.      and immediately  following, a list of  file objects -- referred  to as the
  2988.      FABO list.  Unlike  the directory, however, the FABO list  does not neces-
  2989.      sarily  identify all  objects  in  the file;  it  only  contains those  of
  2990.      interest to the application.
  2991.  
  2992.      The overall directory control block is:
  2993.  
  2994.             File Access Block
  2995.               File Access Block Header
  2996.               FABO - first object
  2997.               FABO - next object
  2998.                       .
  2999.                       .
  3000.               FABO - last object
  3001.             End of File Access Block
  3002.  
  3003.        ; ** File Access Block Header **
  3004.        ; _________________________
  3005.             fabh     struc
  3006.                                       ;
  3007.             fabbit    dw              ; FAB status flag
  3008.             fabcnt    dw              ; Number of FABO'S in FABO list
  3009.             fabhdl    dw              ; File handle
  3010.             fabver    dw              ; Version/modification number
  3011.             reserve1  db  2  dup      ; Reserved - compatibility
  3012.             fabtyp    dw              ; File type
  3013.             reserve2  db 10  dup      ; Reserved - compatibility
  3014.             fabnam    db 64  dup      ; ASCII-z file name
  3015.             reserve3  db  8  dup      ; Reserved- expansion
  3016.             fabstat   dw              ; FAB commit flag
  3017.             fabh     ends
  3018.  
  3019.      The fields in  the File Access Block Header are  defined below.  Any field
  3020.      where specific  values are  not given  should be set  to zero  for compat-
  3021.      ibility with other products.  Likewise,  any reserved fields should be set
  3022.      to zero.
  3023.  
  3024.      The fields in the File Access Block Header can have the following values:
  3025.  
  3026.      1.  FABBIT - Status flags - None currently defined
  3027.  
  3028.      2.  FABCNT - Number of FABO's is a count of elements in the FABO array.
  3029.  
  3030.      3.  FABHDL - Operating system file handle for audio file.
  3031.  
  3032.      4.  FABVER - Equivalent to the directory version number.
  3033.  
  3034.      5.  RESERVE1 - A reserved area for product compatibility.
  3035.  
  3036.      6.  FABTYP - The following types are valid:
  3037.  
  3038.  
  3039.                                           6.  AVC Audio File Format  59
  3040.  
  3041.  
  3042.  
  3043.          ∙   Audio File - 0x0500
  3044.  
  3045.      7.  RESERVE2 - A reserved area for product compatibility.
  3046.  
  3047.      8.  FABNAM - ASCII-z reference string (name of file)
  3048.  
  3049.      9.  RESERVE3 - A reserved area for future expansion.
  3050.  
  3051.      10. FABSTAT  - 0x0080 - FAB has been committed
  3052.  
  3053.        ; ** File Access Block Object **
  3054.        ; _________________________
  3055.             fabo     struc
  3056.                                       ;
  3057.             fostat    dw              ; Object status flags
  3058.                                           0x0001 = Data section modified
  3059.                                           0x0002 = Data section in memory
  3060.                                           0x0010 = Header section modified
  3061.                                           0x0020 = Header section is in memory
  3062.                                           0x0080 = Object is on disk
  3063.                                           0x0100 = Data section is  allocated
  3064.                                           0x0200 = Header section is allocated
  3065.                                           0x2000 = Escape file open
  3066.             fotype    dw              ; Object type code
  3067.             fosub     dw              ; Object subtype
  3068.             fosizh    dw              ; Size of header section
  3069.             fosizv    dd              ; Size of data section
  3070.             reserve1  db  5  dup      ; Reserved - compatibility
  3071.             fohdptr   dd              ; Pointer to header section
  3072.             fabo     ends
  3073.  
  3074.      The fields in  the File Access Block Object are  defined below.  Any field
  3075.      where specific  values are  not given  should be set  to zero  for compat-
  3076.      ibility with other products.  Likewise,  any reserved fields should be set
  3077.      to zero.
  3078.  
  3079.      1.  FOSTAT - Process and error flags.  See above for bit values.
  3080.  
  3081.      2.  FOTYPE - The following types are valid:
  3082.  
  3083.          ∙   Audio  - 0x0500
  3084.  
  3085.          ∙   Volume - 0x0501
  3086.  
  3087.          ∙   Points - 0x0502
  3088.  
  3089.          ∙   Labels - 0x0503
  3090.  
  3091.          ∙   Escape - 0x8500
  3092.  
  3093.      3.  FOSUB- Object subtype is the same as the directory entry.
  3094.  
  3095.  
  3096.  
  3097.                                           6.  AVC Audio File Format  60
  3098.  
  3099.  
  3100.  
  3101.      4.  FOSIZH - Size of  the header in memory is always  16 bytes larger than
  3102.          the size  on disk,  since the memory  header contains  memory location
  3103.          information about the data piece of the object.
  3104.  
  3105.      5.  FOSIZV - Size of the data section.
  3106.  
  3107.      6.  RESERVE1 - A reserved area for product compatibility.
  3108.  
  3109.      7.  FOHDPTR -  A pointer to the  header section.  The header  in memory in
  3110.          turn contains a pointer to the data section.
  3111.  
  3112.  
  3113.                                           6.  AVC Audio File Format  61
  3114.  
  3115.  
  3116.  
  3117.      6.2.3  AUDIO OBJECTS
  3118.  
  3119.      Each object consists of a header and  data section.  All objects of a par-
  3120.      ticular type have  the same header size and layout.   Among objects of the
  3121.      same type, data  sections tend to differ from one  another is size, though
  3122.      not in general structure.
  3123.  
  3124.      An object's header has three parts, the  first two which are common to all
  3125.      objects, no matter what  the object type.  The first is  a set of run_time
  3126.      fields with  memory location  information for  the object's  data section;
  3127.      these fields exist only in the memory representation of the object and are
  3128.      not saved on disk.  The second part is a standard prologue whose principal
  3129.      use is to assist in finding the  object in memory or file dumps.  The rest
  3130.      of the header is data unique to the particular object type.
  3131.  
  3132.      The overall layout of an object header is:
  3133.  
  3134.             Object Header
  3135.               Common memory section
  3136.               Common prologue
  3137.               Unique to object section
  3138.             End of Object Header
  3139.  
  3140.        ; ** Object Header Common Memory  **
  3141.        ; _________________________
  3142.             obmem    struc
  3143.                                       ;
  3144.             dataptr   dd              ; Pointer to start of data section
  3145.    |        reserve1  db 26  dup      ; Reserved - expansion
  3146.    |        mem_id    dw              ; Memory type
  3147.                                       ; 0x00 = Not allocated
  3148.                                       ; 0x01 = Main memory
  3149.                                       ; 0x02 = LIM memory
  3150.                                       ; 0x03 = Device
  3151.             fabh     ends
  3152.  
  3153.      The fields in  the Object Header Common Memory section  are defined below.
  3154.      Any field where  specific values are not  given should be set  to zero for
  3155.      compatibility with  other products.  Likewise, any  reserved fields should
  3156.      be set to zero.
  3157.  
  3158.      1.  DATAPTR - The address of the data section of the object.
  3159.  
  3160.      2.  RESERVE1 - A reserved area for expansion
  3161.  
  3162.      3.  MEM_ID - Type of memory for data section.  See above for types.
  3163.  
  3164.  
  3165.                                           6.  AVC Audio File Format  62
  3166.  
  3167.  
  3168.  
  3169.        ; ** Object Header Common Prologue **
  3170.        ; _________________________
  3171.             obmem    struc
  3172.                                       ;
  3173.             obj_ids   db  8  dup      ; Visual ID and null terminator
  3174.             obj_ver   dw              ; Version
  3175.             cmp_typ   dw              ; Compression type
  3176.             reserve1  db  4  dup      ; Reserved
  3177.             fabh     ends
  3178.  
  3179.      The fields  in the Object Header  Common Prologue are defined  below.  Any
  3180.      field where specific values  are not given should be set  to zero for com-
  3181.      patibility with other  products.  Likewise, any reserved  fields should be
  3182.      set to zero.
  3183.  
  3184.      1.  OBJ_ID - A seven character literal string that identifies a particular
  3185.          object type.  The following IDs are valid:
  3186.  
  3187.          ∙   Audio Object  - "AUDIO  "
  3188.  
  3189.          ∙   Volume Object - "AUDVOL "
  3190.  
  3191.          ∙   Points Object - "AUDPNTS"
  3192.  
  3193.          ∙   Labels Object - "AUDLABL"
  3194.  
  3195.          ∙   Escape Object - "ESCAPE "
  3196.  
  3197.      2.  OBJ_VER - Indicates  the level of the object,  permitting functions to
  3198.          recognize and possibly process down_level formats.
  3199.  
  3200.      3.  CMP_TYPE - A  code applicable to objects whose data  section is stored
  3201.          in compressed form in the file.  It indicates a particular compression
  3202.          algorithm.
  3203.  
  3204.      4.  RESERVE1 - A reserved area for expansion.
  3205.  
  3206.      6.2.3.1  Object Descriptions
  3207.  
  3208.      The unique header  fields and data sections are different  for each object
  3209.      and are described below.
  3210.  
  3211.      AUDIO OBJECT  DESCRIPTION:  The audio header  occupies 64 bytes in  a file
  3212.      and 80 in memory.
  3213.  
  3214.  
  3215.                                           6.  AVC Audio File Format  63
  3216.  
  3217.  
  3218.  
  3219.        ; ** Audio Object Header Structure  **
  3220.        ; _________________________
  3221.             audobjh  struc
  3222.                                       ;
  3223.             com_mem   db  32 dup      ; Common memory structure
  3224.             com_pro   db  16 dup      ; Common prologue structure
  3225.             aud_time  dd              ; Length of audio in milliseconds
  3226.             aud_end   dd              ; Offset to end of segment data
  3227.             aud_segm  dw              ; Length of segment in milliseconds
  3228.             aud_segb  dw              ; Length of segment in bytes
  3229.             aud_dion  dw              ; # of segment index entries
  3230.             aud_dil   dw              ; Length of a segment index entry (bytes)
  3231.             aud_blks  dw              ; Total number of physical segments
  3232.             aud_grb   dw              ; Total number of garbage segments
  3233.             aud_fg1   db              ; Format flag
  3234.                                       ; 0x80 = Fragmented
  3235.                                       ; 0x40 = Sequential
  3236.                                       ; 0x20 = Silence segment at start of
  3237.                                       ;        escape file
  3238.             aud_fg2   db              ; Coding type
  3239.                                       ; 0x80 = Fixed rate coding
  3240.                                       ; 0x40 = Variable rate coding
  3241.                                       ; 0x20 = Variable segment size
  3242.                                       ; 0x10 = Variable segment time
  3243.             aud_comp  dw              ; Compression method
  3244.                                       ; 0x00 = Default - ADPCM/11K
  3245.                                       ; 0x01 = ADPCM 11.0K (mono)
  3246.                                       ; 0x02 = ADPCM  5.5K (mono)
  3247.                                       ; 0x03 = ADPCM 22.0K (stereo)
  3248.                                       ; 0x04 = ADPCM 22.0K (mono)
  3249.                                       ; 0x64 = AVC MIDI
  3250.             aud_mcid  dw              ; Microcode ID
  3251.                                       ; 0x00 = Pre-release version
  3252.                                       ; 0x01 = Post-release (V1.02 and up)
  3253.             reserve1  db  22 dup      ; Reserved
  3254.             audobjh  ends
  3255.  
  3256.      An audio  object's data  section is  a simple  continuous array  of 3-byte
  3257.      offsets to the  digital audio, based on the premise  of fixed rate coding.
  3258.      The index entry size allows for 24 minutes of audio when digitizing at 11k
  3259.      bytes per second.
  3260.  
  3261.        ; ** Audio Object Data Structure  **
  3262.        ; _________________________
  3263.             audobjd  struc
  3264.                                       ;
  3265.             aud_dof   db   3 dup      ; Offset to digital data segment
  3266.             audobjd  ends
  3267.  
  3268.      VOLUME OBJECT DESCRIPTION:   The audio header occupies 32 bytes  in a file
  3269.      and 48 in memory.
  3270.  
  3271.  
  3272.                                           6.  AVC Audio File Format  64
  3273.  
  3274.  
  3275.  
  3276.        ; ** Volume Object Header Structure  **
  3277.        ; _________________________
  3278.             volobjh  struc
  3279.                                       ;
  3280.             com_mem   db  32 dup      ; Common memory structure
  3281.             com_pro   db  16 dup      ; Common prologue structure
  3282.             aud_voln  dw              ; # of volume data entries
  3283.             reserve1  db  14 dup      ; Reserved for expansion
  3284.             volobjh  ends
  3285.  
  3286.      A volume object's data section is a simple array of 1-byte volume codes.
  3287.  
  3288.        ; ** Audio Object Data Structure  **
  3289.        ; _________________________
  3290.             volobjd  struc
  3291.                                       ;
  3292.             aud_vol   db              ; Volume data
  3293.                                       ;  Stereo - Left  Nibble  = Left track
  3294.                                       ;           Right Nibble =  Right track
  3295.                                       ;  Mono   - Right Nibble = Valid
  3296.                                       ;           Left  Nibble = Undefined
  3297.                                       ; Sum of
  3298.                                       ;  bits 0,1,2 / Input RMS Voltage
  3299.                                       ;   0         /      0
  3300.                                       ;  1-3        / .001 -  .06
  3301.                                       ;   4         / .06  -  .12
  3302.                                       ;   5         / .12  -  .24
  3303.                                       ;   6         / .24  -  .47
  3304.                                       ;   7         / .47  - 2.4
  3305.                                       ; Bit 3
  3306.                                       ;   On  = Clipping occurred
  3307.             volobjd  ends
  3308.  
  3309.      POINTS OBJECT DESCRIPTION:  The points header  occupies 32 bytes in a file
  3310.      and 48 in memory.
  3311.  
  3312.        ; ** Points Object Header Structure  **
  3313.        ; _________________________
  3314.             pntobjh  struc
  3315.                                       ;
  3316.             com_mem   db  32 dup      ; Common memory structure
  3317.             com_pro   db  16 dup      ; Common prologue structure
  3318.             aud_plon  dw              ; Number of point list entries
  3319.             reserve1  db  14 dup      ; Reserved for expansion
  3320.             pntobjh  ends
  3321.  
  3322.      A point object's data section is an array of 76-byte audio points
  3323.  
  3324.  
  3325.                                           6.  AVC Audio File Format  65
  3326.  
  3327.  
  3328.  
  3329.        ; ** Audio Points Data Structure  **
  3330.        ; _________________________
  3331.             pntobjd  struc
  3332.                                       ;
  3333.             aud_ptm   dd              ; Point position in time (milliseconds)
  3334.             aud_plb   db   6 dup      ; Label for point - ASCII-z
  3335.             aud_pcm   db  41 dup      ; User annotation of point - ASCII-z
  3336.             aud_ppc   db   8 dup      ; Mix program - command - ASCII-z
  3337.             aud_ppl   db   5 dup      ; Mix program - level - ASCII-z
  3338.             aud_ppt   db   5 dup      ; Mix program - time - ASCII-z
  3339.             aud_pfl   db              ; Point flag
  3340.             reserve1  db   6 dup      ; Reserved for expansion
  3341.             pntobjd  ends
  3342.  
  3343.      LABELS OBJECT DESCRIPTION:  The labels header  occupies 32 bytes in a file
  3344.      and 48 in memory.
  3345.  
  3346.        ; ** Labels Object Header Structure  **
  3347.        ; _________________________
  3348.             labobjh  struc
  3349.                                       ;
  3350.             com_mem   db  32 dup      ; Common memory structure
  3351.             com_pro   db  16 dup      ; Common prologue structure
  3352.             aud_lbln  dw              ; Number of labels entries
  3353.             reserve1  db  14 dup      ; Reserved for expansion
  3354.             labobjh  ends
  3355.  
  3356.      A point object's data section is an array of 12-byte audio labels
  3357.  
  3358.        ; ** Audio Points Data Structure  **
  3359.        ; _________________________
  3360.             pntobjd  struc
  3361.                                       ;
  3362.             aud_ltm   dd              ; Point position in time (milliseconds)
  3363.             aud_lbl   db   6 dup      ; Label for point - ASCII-z
  3364.             reserve1  db   2 dup      ; Reserved for expansion
  3365.  
  3366.      ESCAPE FILE  REFERENCE OBJECT DESCRIPTION:   An escape file  contains data
  3367.      which is too big  and unwieldy to be handled within  a normal data section
  3368.      of an object.  The  escape file is associated with an  audio file, and the
  3369.      audio file contains an "escape file reference object" to describe the sep-
  3370.      arate escape file.
  3371.  
  3372.      An  escape file  reference object  has  only a  header; there  is no  data
  3373.      section (this  is the data in  the escape file).  The  header occupies 112
  3374.      bytes in the file and 128 in memory.
  3375.  
  3376.  
  3377.                                           6.  AVC Audio File Format  66
  3378.  
  3379.  
  3380.  
  3381.        ; ** Escape File Reference Object Header Structure  **
  3382.        ; _________________________
  3383.             escobjh  struc
  3384.                                       ;
  3385.             com_mem   db  32 dup      ; Common memory structure
  3386.             com_pro   db  16 dup      ; Common prologue structure
  3387.             reserve1  db   2 dup      ; Reserved - compatibility
  3388.             esc_sig   dw              ; Signature flag
  3389.                                       ; 0x00 = Standard signature
  3390.                                       ; 0x01 = No signature
  3391.             reserve2  db   8 dup      ; Reserved - compatibility
  3392.             esc_ref   db  64 dup      ; ASCII-z name of escape file
  3393.             esc_hdl   dw              ; Escape file handle
  3394.             esc_thl   dw              ; Temporary escape file handle
  3395.             reserve3  db  16 dup      ; Reserved for expansion
  3396.             escobjh  ends
  3397.  
  3398.      The first 32  bytes of the escape  file is a file signature  with the fol-
  3399.      lowing layout:
  3400.  
  3401.        ; ** Escape File Signature  Structure  **
  3402.        ; _________________________
  3403.             escsgnh  struc
  3404.                                       ;
  3405.             sgn_sgn   db   8 dup      ; ASCII-z signature
  3406.                                       ; AVC = "+A+V+C+"
  3407.             sgn_ver   dw              ; Version modification
  3408.             sgn_type  dw              ; File type
  3409.                                       ; 0x8000 = Escape file
  3410.             reserve1  db   8 dup      ; Reserved - compatibility
  3411.             reserved  db  12 dup      ; Reserved - expansion
  3412.             escsgnh  ends
  3413.  
  3414.  
  3415.                                           6.  AVC Audio File Format  67
  3416.  
  3417.  
  3418.  
  3419.      7.  RIFF WAVE AUDIO FILE FORMAT
  3420.      _______________________________
  3421.  
  3422.  
  3423.      7.1  AUDIO FILE OVERVIEW
  3424.      ________________________
  3425.  
  3426.      The AAPI  supports the Microsoft  Resource Interchange File  Format (RIFF)
  3427.      Waveform Audio  File Format (WAVE).   Users should refer to  the Microsoft
  3428.      Multimedia Development Kit for details of this format.
  3429.  
  3430.      The AAPI  supports the Microsoft  Resource Interchange File  Format (RIFF)
  3431.      Waveform Audio  File Format (WAVE).   Users should refer to  the Microsoft
  3432.      Multimedia Development Kit for details of this format.
  3433.  
  3434.      If the AAPI file level functions (FAB_TYPE, FAB_ROPN, FAB_SAVE, FAB_CLOSE)
  3435.      are used  then detailed knowledge  of the RIFF  WAVE format should  not be
  3436.      necessary.   Once RIFF  WAVE files  have been  read into  memory they  are
  3437.      represented using  the AVC file format  structures so that the  AAPI audio
  3438.      control functions can work transparently on both types of files.
  3439.  
  3440.  
  3441.                                     7.  RIFF WAVE Audio File Format  68
  3442.  
  3443.  
  3444.  
  3445.  
  3446.      APPENDIX A.  OS/2 CONSIDERATIONS
  3447.      ________________________________
  3448.  
  3449.  
  3450.      A.1   OS/2 USAGE
  3451.      ________________
  3452.  
  3453.      The OS/2 version  of the AAPI is  shipped as a dynamic  link library (DLL)
  3454.      and an accompanying import library.   The user statically links the appli-
  3455.      cation with  the import library and  then places the DLL  somewhere in the
  3456.      operating system's DLL path.
  3457.  
  3458.      All calls to the DLL must be far calls and all pointers passed must be far
  3459.      data pointers.
  3460.  
  3461.      A.2   OS/2 DEVICE DRIVER
  3462.      ________________________
  3463.  
  3464.      When running an application using the AAPI under OS/2 the following state-
  3465.      ments must be added to the CONFIG.SYS file:
  3466.  
  3467.              DEVICE=\Your_Device_Path\M-ACPA_OS/2_Device_Driver_Name
  3468.  
  3469.              IOPL=YES
  3470.  
  3471.      The device driver must be installed even if the DOS version of the AAPI is
  3472.      being used in the DOS  Compatibility box.  The compatibility device driver
  3473.      for AVC must be  installed if the AAPI application is going  to be used in
  3474.      OS/2 or any other application other than  the AAPI is going  to access the
  3475.      M-ACPA card.  If AAPI applications only are going to be run in the DOS box
  3476.      then the minimal device driver may  be used.  See the M-ACPA Device Driver
  3477.      document for more details.
  3478.  
  3479.  
  3480.                                    Appendix A.  OS/2 Considerations  69
  3481.  
  3482.  
  3483.  
  3484.      APPENDIX B.  DOS CONSIDERATIONS
  3485.      _______________________________
  3486.  
  3487.  
  3488.      B.1   DOS USAGE
  3489.      _______________
  3490.  
  3491.      In DOS  the AAPI is delivered  as a large  model C library that  should be
  3492.      statically linked with the application.
  3493.  
  3494.      The AAPI routines were compiled using the Microsoft C 6.00 Compiler.
  3495.  
  3496.      B.2   DOS DEVICE DRIVER
  3497.      _______________________
  3498.  
  3499.      When running an application using the  AAPI under DOS the following state-
  3500.      ment must be added to the CONFIG.SYS file:
  3501.  
  3502.             DEVICE = \Your_Device_path\M-ACPA_DOS_Device_Driver_Name
  3503.  
  3504.      The minimal or full function M_ACPA driver may be used.  If no other audio
  3505.      applications are  using the M_ACPA then  use the minimal driver.   If more
  3506.      than one application other than AAPI  applications may be using the M_ACPA
  3507.      then use  the full function device  driver.  See the M-ACPA  Device Driver
  3508.      documentation for more details.
  3509.  
  3510.      B.3   DOS REENTRANCY
  3511.      ____________________
  3512.  
  3513.      Using  the Audio  API under  DOS will  result in  the Audio  API interrupt
  3514.      handler being  invoked at random times.   Since DOS is not  reentrant, the
  3515.      interrupt handler  checks the DOS  critical section flag before  using any
  3516.      DOS services (such as for disk I/O).  The AAPI caller should not structure
  3517.      the application program in a way that leaves this critical section flag on
  3518.      for long  periods of time.  This  will prevent the interrupt  handler from
  3519.      using DOS services.  For example, using DOS  calls in a very tight loop to
  3520.      poll the user for input could cause this situation.
  3521.  
  3522.      B.4   EXPANDED MEMORY
  3523.      _____________________
  3524.  
  3525.      If expanded memory is being used,  the LIM device driver must meet certain
  3526.      performance requirements  and be re-entrant  for the AAPI to  perform ade-
  3527.      quately.  All device drivers we have  tested have been acceptable with the
  3528.      exception of the DOS 4.0 XMAEMS/XMAEM combination on 386 machines.  XMAEMS
  3529.      on 286 machines does have acceptable performance.
  3530.  
  3531.  
  3532.                                     Appendix B.  DOS Considerations  70
  3533.  
  3534.  
  3535.  
  3536.      APPENDIX C.  ADDITIONAL INFORMATION ON PCM SUPPORT
  3537.      __________________________________________________
  3538.  
  3539.  
  3540.      C.1  SIGNIFICANCE OF THE DIFFERENT PCM MODES
  3541.      ____________________________________________
  3542.  
  3543.      PCM or Pulse Code Modulation is  a method of encoding sound information as
  3544.      a series  of numerical sound samples.  The current PCM support  allows the
  3545.      user to  record and  play data at  a variety of  sample widths  and sample
  3546.      rates. The choice of which sample rate and  width to use is essentially an
  3547.      economic trade-off between storage size and sound quality.
  3548.  
  3549.      C.1.1  SAMPLE RATE
  3550.  
  3551.      The choice  of sample rate determines  the highest frequency which  can be
  3552.      represented by the sampled sound data.  Consider the problem of sampling a
  3553.      relatively low frequency sound signal:
  3554.  
  3555.                        Low Frequency Sound
  3556.                        -------------------
  3557.                    *
  3558.               *        *
  3559.            *            |  *
  3560.          * |            |   *
  3561.         *  |            |    *
  3562.        *   |            |     *                   *
  3563.            |            |      *                 *|
  3564.            |            |       *               * |
  3565.            |            |         *           *   |
  3566.            |            |            |*    *      |
  3567.            |            |            |            |
  3568.            |            |            |            |
  3569.            V            V            V            V
  3570.                         Sound Samples
  3571.  
  3572.      Clearly the low  frequency sound pictured above can  be represented nicely
  3573.      if we  take samples at  the regular rate shown.  What about a  higher fre-
  3574.      quency sound?
  3575.  
  3576.  
  3577.                  Appendix C.  Additional Information on PCM Support  71
  3578.  
  3579.  
  3580.  
  3581.                        High Frequency Sound
  3582.                        --------------------
  3583.           *           *           *           *
  3584.          * *         * *         * *         * *         *
  3585.            |
  3586.         *  |*       *   *       *   *       *   *       *
  3587.            |            |
  3588.        *   | *     *    |*     *     *     *     *     *
  3589.            |            |            |
  3590.            |  *   *     | *   *      |*   *       *   *
  3591.            |            |            |            |
  3592.            |   * *      |  * *       | * *        |* *
  3593.            |    *       |   *        |  *         | *
  3594.            V            V            V            V
  3595.                         Sound Samples
  3596.  
  3597.      Clearly the higher  frequency sound shown above can not  be represented by
  3598.      samples taken  at the rate  shown.  The low  points of the  signal between
  3599.      each sample would be missed.  That is,  if you did sample the sound at the
  3600.      rate shown,  and then tried  to reconstruct  the signal from  the samples,
  3601.      what you would get would look like this:
  3602.  
  3603.                        High Frequency Sound
  3604.                        --------------------
  3605.  
  3606.            *
  3607.            A     *
  3608.            |            *
  3609.            |            A      *                                        *
  3610.            |            |            *
  3611.            |            |            A     *                     *
  3612.            |            |            |            *       *
  3613.            |            |            |            A
  3614.            |            |            |            |
  3615.            |            |            |            |
  3616.            |            |            |            |
  3617.                         Sound Samples
  3618.  
  3619.      Which does not look like the original signal at all.
  3620.  
  3621.      The  rule here  is that  the theoretical  highest frequency  which can  be
  3622.      represented by a series  of samples is the frequency equal  to half of the
  3623.      sampling rate. This frequency is called the Nyquist frequency.
  3624.  
  3625.      As it turns out, however, the  real application of PCM recording and play-
  3626.      back is slightly more restrictive even than this.
  3627.  
  3628.      If you again examine the figures above showing the result of attempting to
  3629.      sample a frequency higher than the Nyquist frequency, you will notice that
  3630.      not only  is the reconstructed  signal not the original,  it is in  fact a
  3631.      different signal. This  effect is called "aliasing."   Essentially, as one
  3632.      attempts to sample a frequency higher than the Nyquist frequency, what one
  3633.      gets is an "image" which is a  tone whose frequency is equal to the sample
  3634.      rate minus the frequency of the original tone. For example:
  3635.  
  3636.  
  3637.                  Appendix C.  Additional Information on PCM Support  72
  3638.  
  3639.  
  3640.      ∙   You select a record sampling rate of 11025 samples per second.
  3641.  
  3642.      ∙   The Nyquist frequency is 11025/2 = 5512 Hertz.
  3643.  
  3644.      ∙   You attempt to sample a tone of 7000 Hertz.
  3645.  
  3646.      ∙   The tone  recorded will  "look like"  a tone  of 11025  - 7000  = 4025
  3647.          Hertz.
  3648.  
  3649.      In order  to prevent this  sort of  "aliasing," the PCM  support microcode
  3650.      must digitally  filter out frequencies  higher than the  Nyquist frequency
  3651.      for each  sampling rate.  In an  ideal world  (of unlimited  free digital
  3652.      signal processing  power) one could  have a so-called  "brick-wall" filter
  3653.      which  would  leave frequencies  below  the  Nyquist frequency  completely
  3654.      undisturbed  and also  absolutely and  completely eliminate  any frequency
  3655.      above the  Nyquist frequency.  Real digital filters,  however, are  not so
  3656.      perfectly precise  and must be designed  with a certain amount  of safety.
  3657.      The approximate  bandwidth of the  current PCM  support for the  M-ACPA at
  3658.      different sample rates is shown below:
  3659.  
  3660.                Sample Rate             Maximum Frequency
  3661.                -----------             -----------------
  3662.  
  3663.              8000  samples/sec           3000  Hertz
  3664.  
  3665.              11025 samples/sec           4450  Hertz
  3666.  
  3667.              22050 samples/sec           9200  Hertz
  3668.  
  3669.              44100 samples/sec          20000  Hertz
  3670.  
  3671.      C.1.2  SAMPLE WIDTH
  3672.  
  3673.      The sound quality is  also greatly affected by the number  of bits used to
  3674.      store each sound sample. The choices for storing sound samples are:
  3675.  
  3676.      ∙   8-bit integer
  3677.  
  3678.      ∙   16-bit integer
  3679.  
  3680.      ∙   effective  14-bit   integer  (mu-Law)  (see  C.2, "Mu-Law   and  A-Law
  3681.          Companding" on page 76)
  3682.  
  3683.      ∙   effective  13-bit   integer  (A-Law)   (see  C.2, "Mu-Law   and  A-Law
  3684.          Companding" on page 76)
  3685.  
  3686.      The significant effect of  the number of bits used is  the amount of back-
  3687.      ground hiss perceived  by the listener. This hiss is  actually the audible
  3688.      effect of quantization error or the error introduced when the continuously
  3689.      variable sound level  is assigned to the nearest integer  for storage as a
  3690.      sample.
  3691.  
  3692.  
  3693.                  Appendix C.  Additional Information on PCM Support  73
  3694.  
  3695.  
  3696.      Consider the  following portion of a  sound signal which we  would like to
  3697.      sample:
  3698.  
  3699.        Nearest Integer
  3700.        Sample Value
  3701.          |
  3702.          V                                                       *
  3703.  
  3704.         37                                                    *
  3705.                                                        *
  3706.  
  3707.                                                     *
  3708.         36
  3709.                                                  *
  3710.                                               *
  3711.                                       *
  3712.         35                      *
  3713.                           *
  3714.                       *
  3715.                    *
  3716.         34   *
  3717.  
  3718.      In order to sample the signal we will have to determine at fixed intervals
  3719.      which of the available integer sample values was nearest to the signal:
  3720.  
  3721.        Nearest Integer
  3722.        Sample Value
  3723.          |
  3724.          V                                                       *
  3725.  
  3726.         37   -     -     -     -     -     -     -     -      *    -
  3727.                                                        *
  3728.  
  3729.                                                     *
  3730.         36   -     -     -     -     -     -     -     -     -     -
  3731.                                                  *
  3732.                                               *
  3733.                                       *
  3734.         35   -     -     -      *    -     -     -     -     -     -
  3735.                           *
  3736.                       *
  3737.                    *
  3738.         34   *     -     -      -    -     -     -     -     -     -
  3739.  
  3740.      The resulting signal ends up sort  of "squared off" looking something like
  3741.      this:
  3742.  
  3743.  
  3744.                  Appendix C.  Additional Information on PCM Support  74
  3745.  
  3746.  
  3747.        Nearest Integer
  3748.        Sample Value
  3749.          |
  3750.          V                                                       *
  3751.                                                                  |
  3752.         37   -     -     -     -     -     -     -     .------*--' -
  3753.                                                        *
  3754.                                                        |
  3755.                                                     *  |
  3756.         36   -     -     -     -     -     -  .--------'     -     -
  3757.                                               |  *
  3758.                                               *
  3759.                                       *       |
  3760.         35   -     -  .---------*-------------'  -     -     -     -
  3761.                       |   *
  3762.                       *
  3763.                    *  |
  3764.         34   *--------'  -      -    -     -     -     -     -     -
  3765.  
  3766.      However, the new "square" version of the signal is definitely not the same
  3767.      as the old smooth  version. In fact, the new version  is equivalent to the
  3768.      sum of the original version of the  signal and an error signal which looks
  3769.      like this:
  3770.  
  3771.         1/2          *                        *                  *
  3772.                      *    *                   *  *     *         *
  3773.          0  *        *          *             *               *  *
  3774.                   *  *                *       *     *            *
  3775.        -1/2          *                        *                  *
  3776.  
  3777.      This error  is in fact  random and  uniformly distributed on  the interval
  3778.      between -1/2 and 1/2.  If you consider the error to be a signal, it has an
  3779.      RMS value of 1/(2 * square-root(3)) or approximately 0.3.
  3780.  
  3781.      Now, if we  use 8-bit numbers to  represent the full scale  of our sampled
  3782.      sound, in  the best case,  a signal  can range from  -128 to +127.  If the
  3783.      sound  is   a  pure  tone,   or  sine  wave,  it   has  a  RMS   value  of
  3784.      127/square-root(2) or approximately 90.
  3785.  
  3786.      In this case, the volume of the  noise represents 0.3/90 or 1/3 percent of
  3787.      the volume of the signal. Alternatively  stated, the signal to noise ratio
  3788.      is 20 * log10 (  90 / 0.3) = 49.5 dB. The signal  is 300 times louder than
  3789.      the noise.  In the  lucky case where you are recording  only sounds of all
  3790.      the same volume (loud) this noise will not be a problem.
  3791.  
  3792.      Unfortunately, most reasonably good music has  a much wider range of small
  3793.      and large sounds  than this. The sound of a  symphony orchestra going full
  3794.      bore is on the  order of 10,000 times louder (from  a sound pressure level
  3795.      point of view) than  the sound of the lone piccolo  playing. Clearly if we
  3796.      set our sample scale  to be able to capture the  full orchestra, the sound
  3797.      of the piccolo will  be lost in the quantization noise if  we use an 8-bit
  3798.      scale.
  3799.  
  3800.  
  3801.                  Appendix C.  Additional Information on PCM Support  75
  3802.  
  3803.  
  3804.  
  3805.      The solution  to this problem  is to use a  16-bit scale. Now  our loudest
  3806.      signal can range from -32768 to 32767. The error, however, still is on the
  3807.      order of 0.3, just  like before. The full scale sine wave  will now have a
  3808.      RMS value of  32767/square-root(2) or approximately 23,170.  In this case,
  3809.      the  ratio of  the loudest  signal  to the  noise is  23,170/0.3 which  is
  3810.      approximately equal to 77,200. We now  have more than enough dynamic range
  3811.      to take care of the the piccolo to full-orchestra span of volume. The the-
  3812.      oretical maximum  signal to  noise ratio is  20 * log10  (77,200) =  98 dB
  3813.      (approximately).
  3814.  
  3815.      There are two things to note about this number:
  3816.  
  3817.      1.  The actual performance of the M-ACPA is less than this. However, expe-
  3818.          rience here  is that the  noise performance of  of the M-ACPA  is good
  3819.          enough so  that most of  the time other factors  such as noise  in the
  3820.          cables, power-line hum  in the amplifier, and so on  are sufficient to
  3821.          mask any noise introduced by the M-ACPA.
  3822.  
  3823.      2.  Some  less-than-scrupulous stereo  manufacturers (almost  all of  them
  3824.          actually) manage  to use  convoluted assumptions like:   "the customer
  3825.          will be  listening to nothing  but square  waves" to skew  this calcu-
  3826.          lation  to show  even  higher signal  to noise  numbers  for their  CD
  3827.          players.
  3828.  
  3829.      3.  In  point of  practice,  in  any environment  other  than an  anechoic
  3830.          chamber  with several  thousand dollars  worth of  the very  best high
  3831.          fidelity studio audio  equipment, anything better than about  50 dB of
  3832.          signal to noise ratio sounds wonderful to the average listener.
  3833.  
  3834.      C.2  MU-LAW AND A-LAW COMPANDING
  3835.      ________________________________
  3836.  
  3837.      The problem  with using 16-bit  integer samples rather than  8-bit integer
  3838.      samples is  that doing  so doubles  the amount of  disk space  required to
  3839.      store the information.
  3840.  
  3841.      The companies involved in  designing digital telephone transmission equip-
  3842.      ment ran  up against this problem  long ago and have  developed a solution
  3843.      which works remarkably well. They use a non-linear scale to code the sound
  3844.      samples into 8-bit values.
  3845.  
  3846.  
  3847.                  Appendix C.  Additional Information on PCM Support  76
  3848.  
  3849.  
  3850.  
  3851.                        Mu-Law Companding Curve
  3852.                        -----------------------
  3853.  
  3854.            127 +                                     -   ---
  3855.        8       |                          -
  3856.                |                   -
  3857.        b       |
  3858.        i       |           -
  3859.        t       |
  3860.            63  |     -
  3861.        v       |   -
  3862.        a       |
  3863.        l       | -
  3864.        u       |
  3865.        e       |-
  3866.             0  +-----------+----------+----------+----------
  3867.                           2048       4096       6144       8159
  3868.                        14-bit signed sample value
  3869.  
  3870.      The actual digital to  analog converter uses either a 13  or 14 bit signed
  3871.      integer scale.  The number obtained is  then mapped to an  8-bit number as
  3872.      shown for storage or transmission.
  3873.  
  3874.      There are two mapping curves in common use in the telephony world for this
  3875.      purpose:
  3876.  
  3877.      Mu-Law    Maps a signed  14-bit number to an 8-bit number.  Mu-law is used
  3878.                in the telephone  networks of the United  States, Canada, Japan,
  3879.                Hong Kong, Taiwan, and Korea.
  3880.  
  3881.      A-Law     Maps a signed 13-bit number to an 8-bit number. A-law is used in
  3882.                the  telephone networks  of all  countries other  than the  ones
  3883.                which use mu-Law.
  3884.  
  3885.      Both of these companding schemes  effectively achieve an apparently higher
  3886.      signal  to noise  ratio by  intentionally distorting  louder signals.  The
  3887.      assumption here  is that most of  what is being recorded  is smaller scale
  3888.      signals most of the time.  For example:
  3889.  
  3890.      1.  With 8-bit linear  encoding, the quantizing error has an  RMS value of
  3891.          0.3 regardless  of whether  the input  signal has an  RMS value  of 90
  3892.          (loud) or an RMS  value of 5 (rather soft).  For  the soft signal, the
  3893.          hiss is 0.3/5 = 6 percent as  loud as the signal which is very notice-
  3894.          able with good audio equipment.  That  is, the small signal would have
  3895.          a signal to noise ratio of only 24 dB.
  3896.  
  3897.      2.  By comparison, with mu-law encoding,  the largest possible signal will
  3898.          have  an RMS  value of  8159/square-root(2)(1) which  is approximately
  3899.          5768. However, the steps  at the upper end of the  mu-law curve are in
  3900.          units of 256.  The RMS value  of the quantization noise will therefore
  3901.  
  3902.      ───────────────
  3903.  
  3904.      (1)  The mu-law scale does not go quite all the way to 8192.
  3905.  
  3906.                  Appendix C.  Additional Information on PCM Support  77
  3907.  
  3908.  
  3909.  
  3910.          be 128/square-root(3)  or about 74. This  will give a signal  to noise
  3911.          ratio for the loud signal of about 20 * log10(5768/74) = 38 dB.
  3912.  
  3913.      3.  The comparable  small signal is  5  / 128 *  8159 = 318 on  the mu-law
  3914.          scale. In this  range, the mu-law companding curve has  a step size of
  3915.          16.   The  RMS value  of  the  quantization  noise will  therefore  be
  3916.          8/square-root(3) or about 4.6. This will  give a signal to noise ratio
  3917.          for the loud signal of about 20 * log10(318/4.6) = 36 dB.
  3918.  
  3919.      The net  effect of mu-law companding  is to evenly scale  the quantization
  3920.      noise so that the  signal to noise ratio is always  about 37 dB regardless
  3921.      of how loud or soft the signal is.
  3922.  
  3923.      Mu-Law and A-Law are always 8-bit and  can be supported at any sample rate
  3924.      stereo or  mono except  44100 samples  per second  stereo.  Only  a single
  3925.      track of mu-Law or A-law PCM can be played back at one time.
  3926.  
  3927.      The  exact definitions  of mu-Law  and A-Law  companding are  available in
  3928.      recommendation  G.711 of  the CCITT  (the United  Nations body  which sets
  3929.      international telephony agreements).
  3930.  
  3931.      C.3  DITHER
  3932.      ___________
  3933.  
  3934.      For applications  which require recording of  8-bit linear data (and  to a
  3935.      lesser extent 14-bit  mu-law and 13-bit A-law data) the  use of dither can
  3936.      significantly improve the quality of the recording of softer signals.
  3937.  
  3938.      The problem  alleviated by  dither is  that of  the extreme  relative dis-
  3939.      tortion of signals whose magnitude is on the order of one bit.  Consider a
  3940.      pure tone whose amplitude is just around one bit.
  3941.  
  3942.          3             *                                *
  3943.                    *       *                        *       *
  3944.  
  3945.                 *             *                  *             *
  3946.  
  3947.               *                *               *                *
  3948.  
  3949.                                 *             *                  *
  3950.  
  3951.          2                         *       *                        *
  3952.                                        *                                *
  3953.  
  3954.      (The tone shown above has a peak to peak amplitude of 1 and a DC offset of
  3955.      2.5)
  3956.  
  3957.      When quantized, this signal will tend to turn very square:
  3958.  
  3959.  
  3960.                  Appendix C.  Additional Information on PCM Support  78
  3961.  
  3962.  
  3963.  
  3964.          3      .------*--------.                .------*---------.
  3965.                 |  *       *    |                |  *       *     |
  3966.                                 |                |                |
  3967.                 *             * |                *             *  |
  3968.                 |               |                |                |
  3969.               * |              *|              * |              * |
  3970.                 |               |                |                |
  3971.                 |               *             *  |               *|
  3972.                 |               |                |                |
  3973.          2  ----'               '--*-------*-----'                '-*------
  3974.                                        *                                *
  3975.  
  3976.      A square  wave like this essentially  represents the original tone  with a
  3977.      tremendous amount  of harmonic  distortion thrown into  it. The  tone will
  3978.      sound very rough and grating.
  3979.  
  3980.      Further problems  arise if the amplitude  of the tone is  varying slightly
  3981.      over time.  If the amplitude  of the signal  shown above were  to decrease
  3982.      slightly, it would simply disappear. A short while later it might reappear
  3983.      again as the amplitude once again became greater than one bit.
  3984.  
  3985.      This phenomenon can be heard easily with good audio equipment by making an
  3986.      8-bit recording  (with dither disabled  - 0  percent) of something  like a
  3987.      French Horn  solo trailing delicately  off to  silence. As the  sound dies
  3988.      away, a very unpleasant crackling noise will be heard.
  3989.  
  3990.      Dither attacks  this problem by inserting  a small amount of  random noise
  3991.      into the signal before quantizing from  16-bits down to 8-bits (or down to
  3992.      14 or 13 bits in the case of  mu-Law and A-Law). The size of the signal is
  3993.      user selectable to be scaled to a range  of up to +/- one bit. The default
  3994.      range for dither is  +/- 1/3 bit. That is, in the  normal case, the M-ACPA
  3995.      microcode  generates a  series  of random  numbers  which have  magnitudes
  3996.      between -1 and 1 and then multiplies them by (the user specified value of)
  3997.      33/100  and adds  them to  the signal  before quantizing  to 8  bits. This
  3998.      dither has the effect of  randomizing the transitions between quantization
  3999.      levels. The signal  shown above might look like this  if dithered with 1/3
  4000.      bit of noise before quantization:
  4001.  
  4002.          3      .---.  *.-------.             .--.     .*---------.
  4003.                 |  *|   |  *    |             |  |  *  |    *     |
  4004.                     |   |       |             |  |     |          |
  4005.                 *   |   |     * |             |  *     |       *  |
  4006.                 |   |   |       |             |  |     |          |
  4007.               * |   |   |      *|             |* |     |        * |
  4008.                 |   |   |       |             |  |     |          |
  4009.                 |   |   |       *             *  |     |         *|
  4010.                 |   |   |       |             |  |     |          |
  4011.          2  ----'   '---'       '--*-------*--'  '-----'          '-*------
  4012.                                        *                                *
  4013.  
  4014.      Dither has two effects in this instance:
  4015.  
  4016.  
  4017.                  Appendix C.  Additional Information on PCM Support  79
  4018.  
  4019.  
  4020.  
  4021.      1.  The shape of the resulting wave  is now no longer regular. This irreg-
  4022.          ular random shape tends to  eliminate the harmonics of the fundamental
  4023.          tone present in the square wave.
  4024.  
  4025.      2.  Because of the occasional addition of +1/3  bit to a high point on the
  4026.          signal or -1/3 bit  to a low point on the signal,  the signal will not
  4027.          die out  completely until it falls  below a peak to  peak amplitude of
  4028.          1/3 bit, considerably smaller than without dither.
  4029.  
  4030.      What is not intuitively obvious but is  born out in theory and in practice
  4031.      is that the original tone is still present in the randomized and quantized
  4032.      signal shown above! That is, if  you average the irregular dithered signal
  4033.      over time, the average will converge to the original tone again.
  4034.  
  4035.      The net  effect is that by  adding some additional background  hiss, small
  4036.      signals will  die out  smoothly. If  the French  Horn solo  recording test
  4037.      described above is repeated with 50  percent dither, the sound of the horn
  4038.      will fade gently into the background hiss without breaking up.
  4039.  
  4040.      Dithering should be quite useful for those needing to produce 8-bit linear
  4041.      recordings  of as  high a  quality as  possible. Note,  however, that  the
  4042.      actual level of the dither is really a matter of subjective opinion. There
  4043.      is  no "right"  answer. The  more dither  you add,  the better  the signal
  4044.      sounds, but  the more  background hiss  you hear  as well.  Many textbooks
  4045.      suggest 33 percent as a good compromise and this is the default value.
  4046.  
  4047.      C.4  VOLUME, BALANCE, RAMP AND PAN
  4048.      __________________________________
  4049.  
  4050.      The M-ACPA supports  the use of volume controls for  both record and play-
  4051.      back. In  the record case,  the volume controls  affect the volume  of the
  4052.      data being recorded as well as the  volume of the monitor. In the playback
  4053.      case, there is a separate and  independent set of volume controls for each
  4054.      track.
  4055.  
  4056.      C.4.1  MASTER VOLUME
  4057.  
  4058.      The master volume is the overall volume setting for the track.
  4059.  
  4060.      1.  Once recording  or playback has  begun, the  master volume can  not be
  4061.          changed.
  4062.  
  4063.      2.  The scale for master volume is 0 to 116.
  4064.  
  4065.          a.  The master volume scale is a logarithmic scale.
  4066.  
  4067.          b.  The default master volume is 100.
  4068.  
  4069.          c.  A value of 100 neither amplifies  nor attenuates a signal.  A full
  4070.              scale signal coming  into the M-ACPA input ports  will be recorded
  4071.              as a full scale  signal in the sound file. A  full scale signal in
  4072.              the sound  file, will be  played as a  full scale signal  from the
  4073.              M-ACPA output ports.
  4074.  
  4075.  
  4076.                  Appendix C.  Additional Information on PCM Support  80
  4077.  
  4078.  
  4079.  
  4080.          d.  An increase of 8 in the  master volume setting doubles the voltage
  4081.              of the signal  being output by the M-ACPA. On  record, an increase
  4082.              of 8 in  the master volume setting doubles the  numerical value of
  4083.              the samples being stored.
  4084.  
  4085.          e.  The maximum track  volume setting of 116 increases  the voltage of
  4086.              the signal being played by 4 which increases its power by 16.  The
  4087.              maximum of 116 represents an amplification of +12dB.
  4088.  
  4089.          f.  An decrease of  8 in the master volume setting  halves the voltage
  4090.              of the signal  being output by the M-ACPA. On  record, an decrease
  4091.              of 8  in the master volume  setting halves the numerical  value of
  4092.              the samples being stored.
  4093.  
  4094.      The ability to increase the volume  is useful for some audio devices which
  4095.      can not supply  a standard full scale  audio signal to the  M-ACPA line in
  4096.      ports. Note,  however, that by amplifying  the input signal by  12 dB, you
  4097.      are effectively  losing 2  bits of  resolution in  your signal.   From the
  4098.      point of  view of quantization  noise, you are  now dealing with  a 14-bit
  4099.      signal rather than  a 16-bit signal.  This effect, however,  does not seem
  4100.      to be perceptible even with very high quality audio equipment.
  4101.  
  4102.      C.4.2  TRACK VOLUME
  4103.  
  4104.      Track volume is used to modify the master volume.  The track volume can be
  4105.      changed during record or playback.  The  track volume ranges from 0 to 100
  4106.      percent and indicates the percentage of the current master volume to use.
  4107.  
  4108.      Note that this is a linear  modification of the logarithmic master volume.
  4109.      Setting master volume to 100 and track  volume to 50 percent, will set the
  4110.      volume as though you had set the master volume to 50.
  4111.  
  4112.      C.4.3  RAMP RATE
  4113.  
  4114.      A ramp (up or down) can be  initiated by changing the current track volume
  4115.      and specifying a number of milliseconds for the change to take place.  For
  4116.      example:
  4117.  
  4118.      1.  The master volume is set to 100.
  4119.  
  4120.      2.  The track volume is set to 100.
  4121.  
  4122.      3.  The track volume is changed to 50 and a ramp time of 5000 milliseconds
  4123.          is specified.
  4124.  
  4125.      4.  After 1 second the effective track volume will have changed to 90.
  4126.  
  4127.      5.  After 2 seconds the effective track volume will have changed to 80.
  4128.  
  4129.      6.  After 5 seconds the ramp will  be complete and the new effective track
  4130.          volume level will be 50.
  4131.  
  4132.  
  4133.                  Appendix C.  Additional Information on PCM Support  81
  4134.  
  4135.  
  4136.  
  4137.      The ramp will sound very smooth and  continuous to a human ear even though
  4138.      the actual voltage  levels are changing in a logarithmic  fashion; such is
  4139.      the nature of the human ear.
  4140.  
  4141.      It is possible to interrupt a ramp  in progress and set a new target level
  4142.      to ramp  to. In  this case, the  ramp will be  between the  last effective
  4143.      level (when the ramp in progress was  interrupted by a new change in track
  4144.      volume) and  the new track  volume. The new ramp  will take the  number of
  4145.      milliseconds specified at the time the new ramp is initiated.
  4146.  
  4147.      C.4.4  BALANCE
  4148.  
  4149.      The balance  control can be  thought of as "percentage  of the way  to the
  4150.      right." The  default of 50 percent  means that the volume  is split evenly
  4151.      between right and left.  100 percent means that the volume  is all the way
  4152.      to the right; 0 percent indicates all the way to the left.
  4153.  
  4154.      The basic  operation of balance  is to modify  track volume which  in turn
  4155.      modifies master volume.  The actual  operation of the balance, however, is
  4156.      not so simple.  The major  complication  arises from the human  perception
  4157.      of sound  levels.   Whereas the human perceives  absolute sound  levels in
  4158.      a logarithmic fashion, unfortunately  the human perceives relative balance
  4159.      of sound  levels (left to right)  in a linear  fashion! If we are  ever to
  4160.      hope to  make a pan (side  to side) operate  smoothly like a ramp  (up and
  4161.      down) this  difference in human perception  forces us to use  a non-linear
  4162.      balance scale to compensate for the logarithmic master volume scale.
  4163.  
  4164.      The effect of balance settings on volume looks like this:
  4165.  
  4166.             116 +L                                             R
  4167.                 |          L                     R
  4168.                 |                  L     R
  4169.             100 +    -     -     -    R    -     -     -     -
  4170.                 |
  4171.                 |                R    |     L
  4172.                 |
  4173.                 |            R        |           L
  4174.                 |
  4175.                 |        R            |               L
  4176.                 |
  4177.                 |     R               |                   L
  4178.                 |
  4179.                 |  R                  |                       L
  4180.               0 +------------------------------------------------
  4181.                 0                     50                       100
  4182.  
  4183.                                 Percent Right
  4184.                                 -------------
  4185.  
  4186.      At the  default of 50  percent, balance has no  effect on volume.   As the
  4187.      volume shifts to one side, it increases  the volume on that side above 100
  4188.      percent while decreasing the volume on the other side.
  4189.  
  4190.  
  4191.                  Appendix C.  Additional Information on PCM Support  82
  4192.  
  4193.  
  4194.  
  4195.      Note that the maximum is still 116. If the master volume is set to 116 and
  4196.      the balance is moved  to one side, the balance curve  will limit itself as
  4197.      it gets to 116.  This effect will  not impair the sense of balance, but it
  4198.      will degrade the smoothness and evenness of a panning action.
  4199.  
  4200.      C.4.5  PAN RATE
  4201.  
  4202.      Pan rate is to balance what ramp rate  is to track volume.  A pan (left or
  4203.      right) can be  initiated by changing the current balance  and specifying a
  4204.      number of milliseconds for the change to take place.  For example:
  4205.  
  4206.      1.  The master volume is set to 100.
  4207.  
  4208.      2.  The track volume is set to 100.
  4209.  
  4210.      3.  The balance is set to 50.
  4211.  
  4212.      4.  The balance  is changed to  0 and a pan  time of 5000  milliseconds is
  4213.          specified.
  4214.  
  4215.      5.  Balance will pan smoothly to the left over 5 seconds.
  4216.  
  4217.      The pan will sound reasonably smooth  and continuous to a human ear unless
  4218.      the application has also simultaneously requested the amplification of the
  4219.      signal (master volume > 100).
  4220.  
  4221.      C.5  SOURCE MIXING
  4222.      __________________
  4223.  
  4224.      Source mixing can be used to add the input from either of the M-ACPA input
  4225.      ports into the output of PCM being played back.
  4226.  
  4227.      1.  Source mix can  either be played on  its own track or  together with a
  4228.          PCM file on a track.
  4229.  
  4230.      2.  Since stereo playback requires single track operation, source mix must
  4231.          be played on the same track as the PCM to mix over a stereo track.
  4232.  
  4233.      3.  Playing source  mix on its  own track with  another track of  mono PCM
  4234.          allows each  to have independent  volume, balance, ramp and  fade con-
  4235.          trols.
  4236.  
  4237.      4.  The options for  input for source mix are microphone,  low gain micro-
  4238.          phone, or stereo  line in (both). Input from only  stereo line left or
  4239.          only stereo line right is not supported.
  4240.  
  4241.      5.  If stereo line both is used as  an input and the PCM file being played
  4242.          is stereo, the  source mix will be  stereo as well. That  is, the left
  4243.          channel of the source  will be mixed with the left  channel of the PCM
  4244.          data and the right channel of the  source will be mixed with the right
  4245.          channel of the PCM data.
  4246.  
  4247.  
  4248.                  Appendix C.  Additional Information on PCM Support  83
  4249.  
  4250.  
  4251.  
  4252.          All other combinations of input and  PCM data will cause source mix to
  4253.          be monophonic.
  4254.  
  4255.  
  4256.                  Appendix C.  Additional Information on PCM Support  84
  4257.  
  4258.